From 41b6b5dec711c02f90bf968b99830cfb0934da53 Mon Sep 17 00:00:00 2001 From: Arc Earth Date: Wed, 6 Aug 2025 22:29:56 +0800 Subject: [PATCH 01/12] optimize(build): build nolonger takes 5 minutes to complete The project is currently spending 5 minutes every time I press the build button, after linking CommunityShaders.dll, without any prompt. Turns out lot of this was the cost from all the `POST_BUILD`` commands attached to CommunityShaders, with `ZIP_TO_DIST` default to `ON`. This change splitted the expensive zip packaging command into seperate Package-XXX targets, where developers can manually build before release. Beside, this change also added proper `cmake --install` support. You can use it to install the AIO package into any folder with `cmake --install ./build/ALL --prefix ` command. With all these change, the default preset can now finish an incremental build in about 10 seconds instead of 5 minutes. --- CMakeLists.txt | 191 +++++++++++++++++++++++++------------------------ 1 file changed, 97 insertions(+), 94 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5dfc027da5..9e7bdf30cc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,6 @@ cmake_minimum_required(VERSION 3.21) +cmake_policy(SET CMP0116 NEW) +set(CMAKE_POLICY_WARNING_CMP0116 OFF) project( CommunityShaders @@ -6,6 +8,11 @@ project( LANGUAGES CXX ) +# default install path +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + set_property(CACHE CMAKE_INSTALL_PREFIX PROPERTY VALUE "${CMAKE_CURRENT_BINARY_DIR}/aio") +endif() + list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") # ######################################################################################################################## @@ -191,33 +198,40 @@ endif() file(GLOB FEATURE_PATHS LIST_DIRECTORIES true ${CMAKE_SOURCE_DIR}/features/*) string(TIMESTAMP UTC_NOW "%Y-%m-%dT%H-%MZ" UTC) +# Append a '/' to the end of each feature path for installation all its contents but not itself +set(FEATURE_PATHS_SLASH ${FEATURE_PATHS}) +list(TRANSFORM FEATURE_PATHS_SLASH APPEND /) + +# Install logic for AIO package +# To copy AIO package at a folder do `${CMAKE_COMMAND} --install ${CMAKE_BINARY_DIR} --prefix ${AIO_DIR}` +install(CODE "file(REMOVE_RECURSE \${CMAKE_INSTALL_PREFIX})") +install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION SKSE/Plugins COMPONENT SKSE) +install(FILES $ DESTINATION SKSE/Plugins COMPONENT SKSE) +install(DIRECTORY ${CMAKE_SOURCE_DIR}/package/ ${FEATURE_PATHS_SLASH} DESTINATION . COMPONENT Shaders) +install(CODE "file(REMOVE \${CMAKE_INSTALL_PREFIX}/Core)" COMPONENT Shaders) + +add_custom_command( + OUTPUT copy_shaders.stamp + COMMAND ${CMAKE_COMMAND} --install ${CMAKE_BINARY_DIR} --prefix ${AIO_DIR} --component Shaders + COMMAND ${CMAKE_COMMAND} -E touch copy_shaders.stamp + DEPENDS ${HLSL_FILES} + COMMENT "Copy shaders" +) + +# Standalone target for preparing shaders for CI validation +# This allows shader validation to run without waiting for the full build +add_custom_target(prepare_shaders + DEPENDS copy_shaders.stamp + COMMENT "Preparing shaders for validation" +) + if(AUTO_PLUGIN_DEPLOYMENT OR AIO_ZIP_TO_DIST) set(AIO_DIR "${CMAKE_CURRENT_BINARY_DIR}/aio") message("Copying package folder with dll/pdb with all features to ${AIO_DIR}") add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E remove_directory "${AIO_DIR}" - COMMAND ${CMAKE_COMMAND} -E make_directory "${AIO_DIR}/SKSE/Plugins" - COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/package "${AIO_DIR}" - COMMAND ${CMAKE_COMMAND} -E copy_directory ${FEATURE_PATHS} "${AIO_DIR}" - COMMAND ${CMAKE_COMMAND} -E copy $ "${AIO_DIR}/SKSE/Plugins/" - COMMAND ${CMAKE_COMMAND} -E copy $ "${AIO_DIR}/SKSE/Plugins/" - COMMAND ${CMAKE_COMMAND} -E remove "${AIO_DIR}/CORE" + COMMAND ${CMAKE_COMMAND} --install ${CMAKE_BINARY_DIR} --prefix ${AIO_DIR} + COMMENT "Copy shaders to AIO" ) - add_custom_command( - OUTPUT copy_shaders.stamp - COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/package "${AIO_DIR}" - COMMAND ${CMAKE_COMMAND} -E copy_directory ${FEATURE_PATHS} "${AIO_DIR}" - COMMAND ${CMAKE_COMMAND} -E touch copy_shaders.stamp - DEPENDS ${HLSL_FILES} - ) - - # Standalone target for preparing shaders for CI validation - # This allows shader validation to run without waiting for the full build - add_custom_target(prepare_shaders - DEPENDS copy_shaders.stamp - COMMENT "Preparing shaders for validation" - ) - endif() # Automatic deployment to CommunityShaders output directory. @@ -225,88 +239,77 @@ if(AUTO_PLUGIN_DEPLOYMENT) foreach(DEPLOY_TARGET $ENV{CommunityShadersOutputDir}) message("Copying AIO to ${DEPLOY_TARGET}") add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_directory ${AIO_DIR} "${DEPLOY_TARGET}" + COMMAND ${CMAKE_COMMAND} --install ${CMAKE_BINARY_DIR} --prefix ${DEPLOY_TARGET} + COMMENT "Copy AIO to ${DEPLOY_TARGET}" ) - - string(MD5 DEPLOY_TARGET_HASH ${DEPLOY_TARGET}) - - add_custom_command( - OUTPUT ${DEPLOY_TARGET_HASH}.stamp - COMMAND ${CMAKE_COMMAND} -E copy_directory "${AIO_DIR}/Shaders" "${DEPLOY_TARGET}/Shaders" - COMMAND ${CMAKE_COMMAND} -E touch ${DEPLOY_TARGET_HASH}.stamp - DEPENDS copy_shaders.stamp - ) - - list(APPEND DEPLOY_TARGET_HASHES ${DEPLOY_TARGET_HASH}.stamp) - endforeach() - - add_custom_target(COPY_SHADERS ALL - DEPENDS - copy_shaders.stamp - ${DEPLOY_TARGET_HASHES} - ) - if(NOT DEFINED ENV{CommunityShadersOutputDir}) message("When using AUTO_PLUGIN_DEPLOYMENT option, you need to set environment variable 'CommunityShadersOutputDir'") endif() endif() -# Zip base CommunityShaders and all addons as their own 7z in dist folder -if(ZIP_TO_DIST) - set(ZIP_DIR "${CMAKE_CURRENT_BINARY_DIR}/zip") - message("Copying base CommunityShader into ${ZIP_DIR}.") - add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E remove_directory "${ZIP_DIR}" ${CMAKE_SOURCE_DIR}/dist - COMMAND ${CMAKE_COMMAND} -E make_directory "${ZIP_DIR}/SKSE/Plugins" ${CMAKE_SOURCE_DIR}/dist - COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/package "${ZIP_DIR}" - COMMAND ${CMAKE_COMMAND} -E copy $ "${ZIP_DIR}/SKSE/Plugins/" - COMMAND ${CMAKE_COMMAND} -E copy $ "${ZIP_DIR}/SKSE/Plugins/" - ) - foreach(FEATURE_PATH ${FEATURE_PATHS}) - if (EXISTS "${FEATURE_PATH}/CORE") - add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E copy_directory ${FEATURE_PATH} "${ZIP_DIR}" - ) - endif() - endforeach() - add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E remove "${ZIP_DIR}/CORE" - ) +set(DIST_PATH "${CMAKE_SOURCE_DIR}/dist") - set(TARGET_ZIP "${PROJECT_NAME}-${UTC_NOW}.7z") - message("Zipping ${ZIP_DIR} to ${CMAKE_SOURCE_DIR}/dist/${TARGET_ZIP}") - add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E tar cf ${CMAKE_SOURCE_DIR}/dist/${TARGET_ZIP} --format=7zip -- . - WORKING_DIRECTORY ${ZIP_DIR} - ) +set(CORE_PACKAGE "${DIST_PATH}/${PROJECT_NAME}-${UTC_NOW}.7z") - foreach(FEATURE_PATH ${FEATURE_PATHS}) - if (EXISTS "${FEATURE_PATH}/CORE") - continue() - endif() - get_filename_component(FEATURE ${FEATURE_PATH} NAME) - message("Zipping ${FEATURE_PATH} to ${CMAKE_SOURCE_DIR}/dist/${FEATURE}-${UTC_NOW}.7z") - add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E tar cf ${CMAKE_SOURCE_DIR}/dist/${FEATURE}-${UTC_NOW}.7z --format=7zip -- . - WORKING_DIRECTORY ${FEATURE_PATH} - ) - endforeach() -endif() +file(GLOB_RECURSE CORE_SOURCES CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/package/*") +# Add SKSE plugin dll as dependency +list(APPEND CORE_SOURCES ${PROJECT_NAME}) -# Create a AIO zip for easier testing -if(AIO_ZIP_TO_DIST) - if(NOT ZIP_TO_DIST) - add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_SOURCE_DIR}/dist - COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_SOURCE_DIR}/dist - ) +set(CORE_FEATURE_PATHS "${CMAKE_SOURCE_DIR}/package/") + +foreach(FEATURE_PATH ${FEATURE_PATHS}) + if (EXISTS "${FEATURE_PATH}/CORE") + list(APPEND CORE_FEATURE_PATHS "\"${FEATURE_PATH}/\"") + file(GLOB_RECURSE FEATURE_SOURCES CONFIGURE_DEPENDS "${FEATURE_PATH}/*") + list(APPEND CORE_SOURCES ${FEATURE_SOURCES}) endif() +endforeach() - set(TARGET_AIO_ZIP "${PROJECT_NAME}_AIO-${UTC_NOW}.7z") - message("Zipping ${AIO_DIR} to ${CMAKE_SOURCE_DIR}/dist/${TARGET_AIO_ZIP}") - add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD - COMMAND ${CMAKE_COMMAND} -E tar cf ${CMAKE_SOURCE_DIR}/dist/${TARGET_AIO_ZIP} --format=7zip -- . - WORKING_DIRECTORY ${AIO_DIR} +set(FEATURE_PATH "${CMAKE_BINARY_DIR}/Core") +file(MAKE_DIRECTORY ${FEATURE_PATH}) +add_custom_command(OUTPUT ${CORE_PACKAGE} + DEPENDS ${CORE_SOURCES} + COMMAND ${CMAKE_COMMAND} --install ${CMAKE_BINARY_DIR} --prefix ${FEATURE_PATH} --component SKSE + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CORE_FEATURE_PATHS} ${FEATURE_PATH} + COMMAND ${CMAKE_COMMAND} -E rm -f -- ${FEATURE_PATH}/Core + COMMAND ${CMAKE_COMMAND} -E tar cfv ${CORE_PACKAGE} --format=7zip -- . + WORKING_DIRECTORY ${FEATURE_PATH} + COMMENT "Creating Core zip package" +) +add_custom_target("Package-Core" DEPENDS ${CORE_PACKAGE}) + +foreach(FEATURE_PATH ${FEATURE_PATHS}) + if (EXISTS "${FEATURE_PATH}/CORE") + continue() + endif() + + list(APPEND CORE_FEATURE_PATHS "\"${FEATURE_PATH}/\"") + file(GLOB_RECURSE FEATURE_SOURCES CONFIGURE_DEPENDS "${FEATURE_PATH}/*") + list(APPEND CORE_SOURCES ${FEATURE_SOURCES}) + + get_filename_component(FEATURE ${FEATURE_PATH} NAME) + set(FEATURE_PACKAGE "${DIST_PATH}/${FEATURE}-${UTC_NOW}.7z") + + add_custom_command(OUTPUT ${FEATURE_PACKAGE} + COMMAND ${CMAKE_COMMAND} -E tar cfv ${FEATURE_PACKAGE} --format=7zip -- . + WORKING_DIRECTORY "${FEATURE_PATH}" + DEPENDS ${FEATURE_SOURCES} + COMMENT "Creating ${FEATURE} zip package" ) -endif() + + string(REPLACE " " "" FEATURE ${FEATURE}) + string(REPLACE "-" "" FEATURE ${FEATURE}) + add_custom_target("Package-${FEATURE}" DEPENDS ${FEATURE_PACKAGE}) +endforeach() + +set(AIO_PACKAGE "${DIST_PATH}/${PROJECT_NAME}_AIO-${UTC_NOW}.7z") +add_custom_command(OUTPUT ${AIO_PACKAGE} + DEPENDS ${CORE_SOURCES} + COMMAND ${CMAKE_COMMAND} --install ${CMAKE_BINARY_DIR} --prefix ${AIO_DIR} + COMMAND ${CMAKE_COMMAND} -E tar cfv ${AIO_PACKAGE} --format=7zip -- . + WORKING_DIRECTORY ${AIO_DIR} + COMMENT "Creating AIO zip package" +) +add_custom_target("Package-AIO" DEPENDS ${AIO_PACKAGE}) + From cc8915b5ddd9c8acedd63466408dfe557c1a1844 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 6 Aug 2025 14:49:35 +0000 Subject: [PATCH 02/12] =?UTF-8?q?style:=20=F0=9F=8E=A8=20apply=20pre-commi?= =?UTF-8?q?t.ci=20formatting?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Automated formatting by clang-format, prettier, and other hooks. See https://pre-commit.ci for details. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9e7bdf30cc..9e1332dada 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -290,7 +290,7 @@ foreach(FEATURE_PATH ${FEATURE_PATHS}) get_filename_component(FEATURE ${FEATURE_PATH} NAME) set(FEATURE_PACKAGE "${DIST_PATH}/${FEATURE}-${UTC_NOW}.7z") - + add_custom_command(OUTPUT ${FEATURE_PACKAGE} COMMAND ${CMAKE_COMMAND} -E tar cfv ${FEATURE_PACKAGE} --format=7zip -- . WORKING_DIRECTORY "${FEATURE_PATH}" From 973bd0114a2bfc4dc42b479d081e776680a8a4da Mon Sep 17 00:00:00 2001 From: Arc Earth Date: Wed, 6 Aug 2025 23:00:32 +0800 Subject: [PATCH 03/12] Fix AI review - Set `AIO_DIR`` earlier before `prepare_shaders`` - Ensure `dist` folder exists --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9e1332dada..c9eee27c5b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -210,6 +210,8 @@ install(FILES $ DESTINATION SKSE/Plugins COMPON install(DIRECTORY ${CMAKE_SOURCE_DIR}/package/ ${FEATURE_PATHS_SLASH} DESTINATION . COMPONENT Shaders) install(CODE "file(REMOVE \${CMAKE_INSTALL_PREFIX}/Core)" COMPONENT Shaders) +set(AIO_DIR "${CMAKE_CURRENT_BINARY_DIR}/aio") + add_custom_command( OUTPUT copy_shaders.stamp COMMAND ${CMAKE_COMMAND} --install ${CMAKE_BINARY_DIR} --prefix ${AIO_DIR} --component Shaders @@ -226,7 +228,6 @@ add_custom_target(prepare_shaders ) if(AUTO_PLUGIN_DEPLOYMENT OR AIO_ZIP_TO_DIST) - set(AIO_DIR "${CMAKE_CURRENT_BINARY_DIR}/aio") message("Copying package folder with dll/pdb with all features to ${AIO_DIR}") add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} --install ${CMAKE_BINARY_DIR} --prefix ${AIO_DIR} From bd328e30c472df773049582397fcba4159c5b6f9 Mon Sep 17 00:00:00 2001 From: Arc Earth Date: Thu, 7 Aug 2025 22:39:51 +0800 Subject: [PATCH 04/12] Fixing CI Updating README.md for build instructions Updating CMakePresets.json, removing unused presets like SE/AE Change AIO folder from POST_BUILD to custom target --- .github/workflows/build.yaml | 5 +- CMakeLists.txt | 40 ++++++--- CMakePresets.json | 89 +++++++------------ README.md | 69 ++++++++------ .../ExtendedTranslucency.hlsli | 2 + 5 files changed, 105 insertions(+), 100 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index c845498d4c..37e3e81c55 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -225,7 +225,7 @@ jobs: uses: lukka/run-cmake@v10 with: configurePreset: ALL - buildPreset: ALL + buildPreset: Package - name: Extract version from CMake id: get_version @@ -421,8 +421,7 @@ jobs: uses: lukka/run-cmake@v10 with: configurePreset: ALL - buildPreset: ALL - buildPresetAdditionalArgs: "['--target prepare_shaders']" + buildPreset: Shaders - name: Setup Python if: steps.check-hlsl.outputs.skip != 'true' diff --git a/CMakeLists.txt b/CMakeLists.txt index c9eee27c5b..6556114a08 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,12 +20,8 @@ list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") # ######################################################################################################################## message("Options:") option(AUTO_PLUGIN_DEPLOYMENT "Copy the build output and addons to env:CommunityShadersOutputDir." OFF) -option(ZIP_TO_DIST "Zip the base mod and addons to their own 7z file in dist." ON) -option(AIO_ZIP_TO_DIST "Zip the base mod and addons to a AIO 7z file in dist." ON) option(TRACY_SUPPORT "Enable support for tracy profiler" OFF) message("\tAuto plugin deployment: ${AUTO_PLUGIN_DEPLOYMENT}") -message("\tZip to dist: ${ZIP_TO_DIST}") -message("\tAIO Zip to dist: ${AIO_ZIP_TO_DIST}") message("\tTracy profiler: ${TRACY_SUPPORT}") # ####################################################################################################################### @@ -210,6 +206,17 @@ install(FILES $ DESTINATION SKSE/Plugins COMPON install(DIRECTORY ${CMAKE_SOURCE_DIR}/package/ ${FEATURE_PATHS_SLASH} DESTINATION . COMPONENT Shaders) install(CODE "file(REMOVE \${CMAKE_INSTALL_PREFIX}/Core)" COMPONENT Shaders) +# Build and install logic complete here +# One can just build the project and install an AIO folder into anywhere with: +# `cmake --install ./build/ALL --prefix ` +# Scripts below defines utility targets for: +# - AIO: install to ./build/ALL/aio +# - Package-AIO: AIO zip package +# - Package-Core: CS-Core zip package +# - Package-: Feature zip packages +# - prepare_shaders: Copying shaders only without build the SKSE plugin +# - (AUTO_PLUGIN_DEPLOYMENT): Run cmake install on CommunityShaders.dll POST_BUILD + set(AIO_DIR "${CMAKE_CURRENT_BINARY_DIR}/aio") add_custom_command( @@ -227,21 +234,13 @@ add_custom_target(prepare_shaders COMMENT "Preparing shaders for validation" ) -if(AUTO_PLUGIN_DEPLOYMENT OR AIO_ZIP_TO_DIST) - message("Copying package folder with dll/pdb with all features to ${AIO_DIR}") - add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD - COMMAND ${CMAKE_COMMAND} --install ${CMAKE_BINARY_DIR} --prefix ${AIO_DIR} - COMMENT "Copy shaders to AIO" - ) -endif() - # Automatic deployment to CommunityShaders output directory. if(AUTO_PLUGIN_DEPLOYMENT) foreach(DEPLOY_TARGET $ENV{CommunityShadersOutputDir}) - message("Copying AIO to ${DEPLOY_TARGET}") + message("Installing to ${DEPLOY_TARGET}") add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} --install ${CMAKE_BINARY_DIR} --prefix ${DEPLOY_TARGET} - COMMENT "Copy AIO to ${DEPLOY_TARGET}" + COMMENT "Installing to ${DEPLOY_TARGET}" ) endforeach() if(NOT DEFINED ENV{CommunityShadersOutputDir}) @@ -250,9 +249,11 @@ if(AUTO_PLUGIN_DEPLOYMENT) endif() set(DIST_PATH "${CMAKE_SOURCE_DIR}/dist") +file(MAKE_DIRECTORY "${CMAKE_SOURCE_DIR}/dist") set(CORE_PACKAGE "${DIST_PATH}/${PROJECT_NAME}-${UTC_NOW}.7z") +# CORE_SOURCES = all content copied to the AIO directory + the SKSE plugin dll file(GLOB_RECURSE CORE_SOURCES CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/package/*") # Add SKSE plugin dll as dependency list(APPEND CORE_SOURCES ${PROJECT_NAME}) @@ -267,6 +268,7 @@ foreach(FEATURE_PATH ${FEATURE_PATHS}) endif() endforeach() +# Core package set(FEATURE_PATH "${CMAKE_BINARY_DIR}/Core") file(MAKE_DIRECTORY ${FEATURE_PATH}) add_custom_command(OUTPUT ${CORE_PACKAGE} @@ -280,6 +282,7 @@ add_custom_command(OUTPUT ${CORE_PACKAGE} ) add_custom_target("Package-Core" DEPENDS ${CORE_PACKAGE}) +# Feature packages foreach(FEATURE_PATH ${FEATURE_PATHS}) if (EXISTS "${FEATURE_PATH}/CORE") continue() @@ -304,6 +307,15 @@ foreach(FEATURE_PATH ${FEATURE_PATHS}) add_custom_target("Package-${FEATURE}" DEPENDS ${FEATURE_PACKAGE}) endforeach() +# AIO Folder +add_custom_command(OUTPUT ${AIO_PACKAGE}/SKSE/Plugins/${PROJECT_NAME}.dll + DEPENDS ${CORE_SOURCES} + COMMAND ${CMAKE_COMMAND} --install ${CMAKE_BINARY_DIR} --prefix ${AIO_DIR} + COMMENT "Installing to AIO folder" +) +add_custom_target("AIO" DEPENDS ${AIO_PACKAGE}/SKSE/Plugins/${PROJECT_NAME}.dll) + +# AIO package set(AIO_PACKAGE "${DIST_PATH}/${PROJECT_NAME}_AIO-${UTC_NOW}.7z") add_custom_command(OUTPUT ${AIO_PACKAGE} DEPENDS ${CORE_SOURCES} diff --git a/CMakePresets.json b/CMakePresets.json index d1f88649e9..f1425cd1bc 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -51,73 +51,46 @@ "hidden": true, "inherits": ["common", "vcpkg", "win64", "msvc"] }, - { - "name": "AE", - "cacheVariables": { - "ENABLE_SKYRIM_AE": "ON", - "ENABLE_SKYRIM_SE": "OFF", - "ENABLE_SKYRIM_VR": "OFF" - }, - "inherits": "skyrim" - }, - { - "name": "SE", - "cacheVariables": { - "ENABLE_SKYRIM_AE": "OFF", - "ENABLE_SKYRIM_SE": "ON", - "ENABLE_SKYRIM_VR": "OFF" - }, - "inherits": "skyrim" - }, - { - "name": "VR", - "cacheVariables": { - "ENABLE_SKYRIM_AE": "OFF", - "ENABLE_SKYRIM_SE": "OFF", - "ENABLE_SKYRIM_VR": "ON" - }, - "inherits": "skyrim" - }, { "name": "ALL", "cacheVariables": { "ENABLE_SKYRIM_AE": "ON", "ENABLE_SKYRIM_SE": "ON", - "ENABLE_SKYRIM_VR": "ON" + "ENABLE_SKYRIM_VR": "ON", + "AUTO_PLUGIN_DEPLOYMENT": "OFF" }, "inherits": "skyrim" - }, - { - "name": "PRE-AE", - "cacheVariables": { - "ENABLE_SKYRIM_AE": "OFF", - "ENABLE_SKYRIM_SE": "ON", - "ENABLE_SKYRIM_VR": "ON" - }, - "inherits": "skyrim" - }, - { - "name": "FLATRIM", - "cacheVariables": { - "ENABLE_SKYRIM_AE": "ON", - "ENABLE_SKYRIM_SE": "ON", - "ENABLE_SKYRIM_VR": "OFF" - }, - "inherits": "skyrim" - }, - { - "name": "ALL-TRACY", - "cacheVariables": { - "TRACY_SUPPORT": "ON" - }, - "inherits": "ALL" } ], "buildPresets": [ - { - "name": "ALL", - "configurePreset": "ALL", - "configuration": "Release" - } + { + "name": "ALL", + "description": "Default build preset for developers, generate files in /aio folder", + "configurePreset": "ALL", + "configuration": "Release", + "targets": [ + "CommunityShaders", + "AIO" + ] + }, + { + "name": "Package", + "description": "Build preset to generate a AIO zip package in /dist folder", + "configurePreset": "ALL", + "configuration": "Release", + "targets": [ + "CommunityShaders", + "Package-AIO" + ] + }, + { + "name": "Shaders", + "description": "Build preset to copy shaders into /AIO folder for shader validation", + "configurePreset": "ALL", + "configuration": "Release", + "targets": [ + "prepare_shaders" + ] + } ] } diff --git a/README.md b/README.md index 3fb25e4975..9386d25929 100644 --- a/README.md +++ b/README.md @@ -40,29 +40,61 @@ SKSE core plugin for community-driven advanced graphics modifications. - [VR Address Library for SKSEVR](https://www.nexusmods.com/skyrimspecialedition/mods/58101) - Needed for VR -## Register Visual Studio as a Generator +## Build Instructions -- Open `x64 Native Tools Command Prompt` -- Run `cmake` -- Close the cmd window +### Clone the Repository with submodules +To clone the repository with all submodules, run the following command in your terminal: +```bash +git clone https://github.com/doodlum/skyrim-community-shaders.git --recursive +cd skyrim-community-shaders +``` + +### Visual Studio build +To build the project, ensure you have CMake support enabled in Visual Studio. You can do this by selecting the "Desktop development with C++" workload during installation. +Just open `./skyrim-community-shaders` with Visual Studio's "Open Folder" feature, and it will automatically detect the CMake project. +Follow the prompts to `Configure` and `Build` the project. +It should generate the AIO package in the `./build/ALL/aio` folder by default. + +#### Zip package & Optional targets +If you change the `Solution Explorer` into `CMake Targets View`, you can find optional targets to create zip packages for each feature. +Right click on the target and select `Build` to create the zip package in `./dist/`. -Or, in powershell run: +### Advanced build with CMake in command line + +In Windows Start menu, search for `x64 Native Tools Command Prompt`, open it in a Cmd or Powershell terminal: ```pwsh +# Same as running `x64 Native Tools Command Prompt` +# Adding cl.exe and cmake.exe into your PATH & "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" amd64 -``` -## Clone and Build +# Change to the repository folder +cd skyrim-community-shaders + +# Generate the build files in ./build/ALL +cmake -S . --preset=ALL -B ./build/ALL -Open terminal (e.g., PowerShell) and run the following commands: +# Invoke build tool to build the C++ source code +# This also generate an AIO folder in ./build/ALL/aio +cmake --build ./build/ALL --preset ALL +# Install an AIO package into anywhere, e.g. $MOD_FOLDER +cmake --install ./build/ALL --prefix $MOD_FOLDER ``` -git clone https://github.com/doodlum/skyrim-community-shaders.git --recursive -cd skyrim-community-shaders -.\BuildRelease.bat + +#### Build a zip package +You can build zip packages for optional cmake targets. +Currently support `Package-AIO`, `Package-Core`, and `Package-`: +```pwsh +# Create a AIO package in ./dist/ +cmake --build ./build/ALL --config Release --target Package-AIO +# Create a CommunityShaders core package in ./dist/ +cmake --build ./build/ALL --config Release --target Package-Core +# Create a feature package in ./dist/ +cmake --build ./build/ALL --config Release --target Package-GrassLighting ``` -### CMAKE Options (optional) +#### CMAKE Options (optional) If you want an example CMakeUserPreset to start off with you can copy the `CMakeUserPresets.json.template` -> `CMakeUserPresets.json` @@ -72,19 +104,6 @@ If you want an example CMakeUserPreset to start off with you can copy the `CMake - Make sure `"AUTO_PLUGIN_DEPLOYMENT"` is set to `"ON"` in `CMakeUserPresets.json` - Change the `"CommunityShadersOutputDir"` value to match your desired outputs, if you want multiple folders you can separate them by `;` is shown in the template example -#### AIO_ZIP_TO_DIST - -- This option is default `"ON"` -- Make sure `"AIO_ZIP_TO_DIST"` is set to `"ON"` in `CMakeUserPresets.json` -- This will create a `CommunityShaders_AIO.7z` archive in /dist containing all features and base mod - -#### ZIP_TO_DIST - -- This option is default `"ON"` -- Make sure `"ZIP_TO_DIST"` is set to `"ON"` in `CMakeUserPresets.json` -- This will create a zip for each feature and one for the base Community shaders in /dist -- If having a file with name `CORE` in the root of the features folder it will instead be merged into the core zip - #### TRACY_SUPPORT - This option is default `"OFF"` diff --git a/features/Extended Translucency/Shaders/ExtendedTranslucency/ExtendedTranslucency.hlsli b/features/Extended Translucency/Shaders/ExtendedTranslucency/ExtendedTranslucency.hlsli index 40a13db510..ee41ccd400 100644 --- a/features/Extended Translucency/Shaders/ExtendedTranslucency/ExtendedTranslucency.hlsli +++ b/features/Extended Translucency/Shaders/ExtendedTranslucency/ExtendedTranslucency.hlsli @@ -7,6 +7,8 @@ namespace ExtendedTranslucency static const uint IsotropicFabric = 2; static const uint AnisotropicFabric = 3; static const uint Disabled = 4; // Any value >= 4 + // Yoyo this is a testing change to trigger CI shader validation + static const uint Placeholder = 5; // Placeholder for future use } bool IsValidMaterial(uint Material) From 87becf17020d1af368eddbe672567abd96afaac9 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 7 Aug 2025 14:42:42 +0000 Subject: [PATCH 05/12] =?UTF-8?q?style:=20=F0=9F=8E=A8=20apply=20pre-commi?= =?UTF-8?q?t.ci=20formatting?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Automated formatting by clang-format, prettier, and other hooks. See https://pre-commit.ci for details. --- CMakeLists.txt | 2 +- CMakePresets.json | 50 ++++++++++++++++++++--------------------------- README.md | 6 ++++++ 3 files changed, 28 insertions(+), 30 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6556114a08..8dac607d58 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -208,7 +208,7 @@ install(CODE "file(REMOVE \${CMAKE_INSTALL_PREFIX}/Core)" COMPONENT Shaders) # Build and install logic complete here # One can just build the project and install an AIO folder into anywhere with: -# `cmake --install ./build/ALL --prefix ` +# `cmake --install ./build/ALL --prefix ` # Scripts below defines utility targets for: # - AIO: install to ./build/ALL/aio # - Package-AIO: AIO zip package diff --git a/CMakePresets.json b/CMakePresets.json index f1425cd1bc..0ed3f89aa9 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -63,34 +63,26 @@ } ], "buildPresets": [ - { - "name": "ALL", - "description": "Default build preset for developers, generate files in /aio folder", - "configurePreset": "ALL", - "configuration": "Release", - "targets": [ - "CommunityShaders", - "AIO" - ] - }, - { - "name": "Package", - "description": "Build preset to generate a AIO zip package in /dist folder", - "configurePreset": "ALL", - "configuration": "Release", - "targets": [ - "CommunityShaders", - "Package-AIO" - ] - }, - { - "name": "Shaders", - "description": "Build preset to copy shaders into /AIO folder for shader validation", - "configurePreset": "ALL", - "configuration": "Release", - "targets": [ - "prepare_shaders" - ] - } + { + "name": "ALL", + "description": "Default build preset for developers, generate files in /aio folder", + "configurePreset": "ALL", + "configuration": "Release", + "targets": ["CommunityShaders", "AIO"] + }, + { + "name": "Package", + "description": "Build preset to generate a AIO zip package in /dist folder", + "configurePreset": "ALL", + "configuration": "Release", + "targets": ["CommunityShaders", "Package-AIO"] + }, + { + "name": "Shaders", + "description": "Build preset to copy shaders into /AIO folder for shader validation", + "configurePreset": "ALL", + "configuration": "Release", + "targets": ["prepare_shaders"] + } ] } diff --git a/README.md b/README.md index 9386d25929..a5d81c0976 100644 --- a/README.md +++ b/README.md @@ -43,19 +43,23 @@ SKSE core plugin for community-driven advanced graphics modifications. ## Build Instructions ### Clone the Repository with submodules + To clone the repository with all submodules, run the following command in your terminal: + ```bash git clone https://github.com/doodlum/skyrim-community-shaders.git --recursive cd skyrim-community-shaders ``` ### Visual Studio build + To build the project, ensure you have CMake support enabled in Visual Studio. You can do this by selecting the "Desktop development with C++" workload during installation. Just open `./skyrim-community-shaders` with Visual Studio's "Open Folder" feature, and it will automatically detect the CMake project. Follow the prompts to `Configure` and `Build` the project. It should generate the AIO package in the `./build/ALL/aio` folder by default. #### Zip package & Optional targets + If you change the `Solution Explorer` into `CMake Targets View`, you can find optional targets to create zip packages for each feature. Right click on the target and select `Build` to create the zip package in `./dist/`. @@ -83,8 +87,10 @@ cmake --install ./build/ALL --prefix $MOD_FOLDER ``` #### Build a zip package + You can build zip packages for optional cmake targets. Currently support `Package-AIO`, `Package-Core`, and `Package-`: + ```pwsh # Create a AIO package in ./dist/ cmake --build ./build/ALL --config Release --target Package-AIO From 7049398cb7f645a6ed39c6db1f7b90aafc612346 Mon Sep 17 00:00:00 2001 From: Arc Earth Date: Fri, 8 Aug 2025 21:28:56 +0800 Subject: [PATCH 06/12] Revert renaming of CMakePresets because CI cannot be updated --- CMakeLists.txt | 4 +-- CMakePresets.json | 74 ++++++++++++++++++++++++++++++++--------------- 2 files changed, 53 insertions(+), 25 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8dac607d58..4fde781356 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -308,12 +308,12 @@ foreach(FEATURE_PATH ${FEATURE_PATHS}) endforeach() # AIO Folder -add_custom_command(OUTPUT ${AIO_PACKAGE}/SKSE/Plugins/${PROJECT_NAME}.dll +add_custom_command(OUTPUT ${AIO_DIR}/SKSE/Plugins/${PROJECT_NAME}.dll DEPENDS ${CORE_SOURCES} COMMAND ${CMAKE_COMMAND} --install ${CMAKE_BINARY_DIR} --prefix ${AIO_DIR} COMMENT "Installing to AIO folder" ) -add_custom_target("AIO" DEPENDS ${AIO_PACKAGE}/SKSE/Plugins/${PROJECT_NAME}.dll) +add_custom_target("AIO" DEPENDS ${AIO_DIR}/SKSE/Plugins/${PROJECT_NAME}.dll) # AIO package set(AIO_PACKAGE "${DIST_PATH}/${PROJECT_NAME}_AIO-${UTC_NOW}.7z") diff --git a/CMakePresets.json b/CMakePresets.json index 0ed3f89aa9..362657aa56 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -62,27 +62,55 @@ "inherits": "skyrim" } ], - "buildPresets": [ - { - "name": "ALL", - "description": "Default build preset for developers, generate files in /aio folder", - "configurePreset": "ALL", - "configuration": "Release", - "targets": ["CommunityShaders", "AIO"] - }, - { - "name": "Package", - "description": "Build preset to generate a AIO zip package in /dist folder", - "configurePreset": "ALL", - "configuration": "Release", - "targets": ["CommunityShaders", "Package-AIO"] - }, - { - "name": "Shaders", - "description": "Build preset to copy shaders into /AIO folder for shader validation", - "configurePreset": "ALL", - "configuration": "Release", - "targets": ["prepare_shaders"] - } - ] + "buildPresets": [ + { + "name": "Dev", + "description": "Default build preset for developers, generate an AIO folder thats ready to copy", + "configurePreset": "ALL", + "configuration": "Release", + "targets": [ + "CommunityShaders", + "AIO" + ] + }, + { + "name": "ALL", + "description": "(Deprecated), kept for for CI, use Package instead", + "configurePreset": "ALL", + "configuration": "Release", + "targets": [ + "CommunityShaders", + "Package-AIO" + ] + }, + { + "name": "Package", + "description": "Build preset to generate a AIO zip package in /dist folder, mostly for CI", + "configurePreset": "ALL", + "configuration": "Release", + "targets": [ + "CommunityShaders", + "Package-AIO" + ] + }, + { + "name": "Shaders", + "description": "Build preset to copy shaders into /AIO folder for shader validation", + "configurePreset": "ALL", + "configuration": "Release", + "targets": [ + "prepare_shaders" + ] + }, + { + "name": "Debug", + "description": "Debug build for CS SKSE plugin, generate an AIO folder thats ready to copy", + "configurePreset": "ALL", + "configuration": "Debug", + "targets": [ + "CommunityShaders", + "AIO" + ] + } + ] } From a0562f042b6ef86c4597b24809463ae60dc80151 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 8 Aug 2025 13:30:10 +0000 Subject: [PATCH 07/12] =?UTF-8?q?style:=20=F0=9F=8E=A8=20apply=20pre-commi?= =?UTF-8?q?t.ci=20formatting?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Automated formatting by clang-format, prettier, and other hooks. See https://pre-commit.ci for details. --- CMakePresets.json | 88 ++++++++++++++++++++--------------------------- 1 file changed, 37 insertions(+), 51 deletions(-) diff --git a/CMakePresets.json b/CMakePresets.json index 362657aa56..b30165bef5 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -62,55 +62,41 @@ "inherits": "skyrim" } ], - "buildPresets": [ - { - "name": "Dev", - "description": "Default build preset for developers, generate an AIO folder thats ready to copy", - "configurePreset": "ALL", - "configuration": "Release", - "targets": [ - "CommunityShaders", - "AIO" - ] - }, - { - "name": "ALL", - "description": "(Deprecated), kept for for CI, use Package instead", - "configurePreset": "ALL", - "configuration": "Release", - "targets": [ - "CommunityShaders", - "Package-AIO" - ] - }, - { - "name": "Package", - "description": "Build preset to generate a AIO zip package in /dist folder, mostly for CI", - "configurePreset": "ALL", - "configuration": "Release", - "targets": [ - "CommunityShaders", - "Package-AIO" - ] - }, - { - "name": "Shaders", - "description": "Build preset to copy shaders into /AIO folder for shader validation", - "configurePreset": "ALL", - "configuration": "Release", - "targets": [ - "prepare_shaders" - ] - }, - { - "name": "Debug", - "description": "Debug build for CS SKSE plugin, generate an AIO folder thats ready to copy", - "configurePreset": "ALL", - "configuration": "Debug", - "targets": [ - "CommunityShaders", - "AIO" - ] - } - ] + "buildPresets": [ + { + "name": "Dev", + "description": "Default build preset for developers, generate an AIO folder thats ready to copy", + "configurePreset": "ALL", + "configuration": "Release", + "targets": ["CommunityShaders", "AIO"] + }, + { + "name": "ALL", + "description": "(Deprecated), kept for for CI, use Package instead", + "configurePreset": "ALL", + "configuration": "Release", + "targets": ["CommunityShaders", "Package-AIO"] + }, + { + "name": "Package", + "description": "Build preset to generate a AIO zip package in /dist folder, mostly for CI", + "configurePreset": "ALL", + "configuration": "Release", + "targets": ["CommunityShaders", "Package-AIO"] + }, + { + "name": "Shaders", + "description": "Build preset to copy shaders into /AIO folder for shader validation", + "configurePreset": "ALL", + "configuration": "Release", + "targets": ["prepare_shaders"] + }, + { + "name": "Debug", + "description": "Debug build for CS SKSE plugin, generate an AIO folder thats ready to copy", + "configurePreset": "ALL", + "configuration": "Debug", + "targets": ["CommunityShaders", "AIO"] + } + ] } From 801e5ce4c4378d047f40e4a226cadd94f3cf3c9f Mon Sep 17 00:00:00 2001 From: Arc Earth Date: Tue, 12 Aug 2025 21:23:18 +0800 Subject: [PATCH 08/12] Revert CI files and testing shaders --- .github/workflows/build.yaml | 5 ++- CMakeLists.txt | 10 +++++ README.md | 41 +++++++++++++++++-- .../ExtendedTranslucency.hlsli | 2 - 4 files changed, 50 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 37e3e81c55..c845498d4c 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -225,7 +225,7 @@ jobs: uses: lukka/run-cmake@v10 with: configurePreset: ALL - buildPreset: Package + buildPreset: ALL - name: Extract version from CMake id: get_version @@ -421,7 +421,8 @@ jobs: uses: lukka/run-cmake@v10 with: configurePreset: ALL - buildPreset: Shaders + buildPreset: ALL + buildPresetAdditionalArgs: "['--target prepare_shaders']" - name: Setup Python if: steps.check-hlsl.outputs.skip != 'true' diff --git a/CMakeLists.txt b/CMakeLists.txt index 4fde781356..e8ea5d24f3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,10 @@ cmake_minimum_required(VERSION 3.21) cmake_policy(SET CMP0116 NEW) set(CMAKE_POLICY_WARNING_CMP0116 OFF) +if (CMAKE_VERSION VERSION_GREATER_EQUAL "4.0.0") + message(ERROR "EASTL will fail to install with vcpkg using cmake 4.0+, remove this line if the port get fixed.") +endif() + project( CommunityShaders VERSION 1.3.4 @@ -326,3 +330,9 @@ add_custom_command(OUTPUT ${AIO_PACKAGE} ) add_custom_target("Package-AIO" DEPENDS ${AIO_PACKAGE}) +message("*************************************************************") +message("Community Shaders configuration complete") +message("To prepare a ZIP package of AIO, Core, or Features") +message(" Build cmake targets 'Package-XXX'") +message("Try switching to build preset 'Dev' for faster iteration time") +message("*************************************************************") diff --git a/README.md b/README.md index a5d81c0976..8abea5cdfe 100644 --- a/README.md +++ b/README.md @@ -23,11 +23,21 @@ SKSE core plugin for community-driven advanced graphics modifications. - Any terminal of your choice (e.g., PowerShell) - [Visual Studio Community 2022](https://visualstudio.microsoft.com/) - Desktop development with C++ + - CMake Tools for Windows + - HLSL Tools +- [Git](https://git-scm.com/downloads) + - Edit the `PATH` environment variable and add the Git.exe install path as a new value + +## Optional Requirements +``` +CMake & Vcpkg comes with Visual Studio in Developer Command Prompts already. +Install them manually only if you want them in everywhere. +``` - [CMake](https://cmake.org/) + - No need to install manually if you have Visual Studio CMake Tools installed + - CMake 4.0+ is __not__ supported right now - Edit the `PATH` environment variable and add the cmake.exe install path as a new value - Instructions for finding and editing the `PATH` environment variable can be found [here](https://www.java.com/en/download/help/path.html) -- [Git](https://git-scm.com/downloads) - - Edit the `PATH` environment variable and add the Git.exe install path as a new value - [Vcpkg](https://github.com/microsoft/vcpkg) - Install vcpkg using the directions in vcpkg's [Quick Start Guide](https://github.com/microsoft/vcpkg#quick-start-windows) - After install, add a new environment variable named `VCPKG_ROOT` with the value as the path to the folder containing vcpkg @@ -53,8 +63,8 @@ cd skyrim-community-shaders ### Visual Studio build -To build the project, ensure you have CMake support enabled in Visual Studio. You can do this by selecting the "Desktop development with C++" workload during installation. -Just open `./skyrim-community-shaders` with Visual Studio's "Open Folder" feature, and it will automatically detect the CMake project. +To build the project, just open `./skyrim-community-shaders` with Visual Studio's "Open Folder" feature. (Ensure you have `CMake Tools for Windows` selected when installing VS) + Follow the prompts to `Configure` and `Build` the project. It should generate the AIO package in the `./build/ALL/aio` folder by default. @@ -82,6 +92,9 @@ cmake -S . --preset=ALL -B ./build/ALL # This also generate an AIO folder in ./build/ALL/aio cmake --build ./build/ALL --preset ALL +# The cmake & cmake --build comamnd are captured in this batch file as well +# ./BuildRelease.bat + # Install an AIO package into anywhere, e.g. $MOD_FOLDER cmake --install ./build/ALL --prefix $MOD_FOLDER ``` @@ -149,6 +162,26 @@ If you run into `Access violation` build errors during step 3, you can try addin docker run -it --rm --isolation=process -v .:C:/skyrim-community-shaders skyrim-community-shaders:latest ``` +## Debugging +### Launching MO2-SKSE-Skyrim from commandline +1. Open Steam +2. Close ModOrganizer GUI +3. Add `ModOrganizer.exe` (MO2 Folder) to your PATH, or use the path of it +4. Run the commands: +```pwsh +# Change Working Directory +cd "C:/Program Files (x86)/Steam/steamapps/common/Skyrim Special Edition" +# Launch SKSE with MO2 +ModOrganizer.exe --log run "C:\Program Files (x86)\Steam\steamapps\common\Skyrim Special Edition\skse64_loader.exe" +``` + +### Capture with RenderDoc +In Launch Application Menu, use the following settings: +- Executable Path: `PATH/TO/ModOrganizer.exe` +- Working Directory: `C:/Program Files (x86)/Steam/steamapps/common/Skyrim Special Edition` +- Command-line Arguments: `--log run "C:\Program Files (x86)\Steam\steamapps\common\Skyrim Special Edition\skse64_loader.exe"` +- [x] __Capture Child Process__ + ## License ### Default diff --git a/features/Extended Translucency/Shaders/ExtendedTranslucency/ExtendedTranslucency.hlsli b/features/Extended Translucency/Shaders/ExtendedTranslucency/ExtendedTranslucency.hlsli index ee41ccd400..40a13db510 100644 --- a/features/Extended Translucency/Shaders/ExtendedTranslucency/ExtendedTranslucency.hlsli +++ b/features/Extended Translucency/Shaders/ExtendedTranslucency/ExtendedTranslucency.hlsli @@ -7,8 +7,6 @@ namespace ExtendedTranslucency static const uint IsotropicFabric = 2; static const uint AnisotropicFabric = 3; static const uint Disabled = 4; // Any value >= 4 - // Yoyo this is a testing change to trigger CI shader validation - static const uint Placeholder = 5; // Placeholder for future use } bool IsValidMaterial(uint Material) From 3726973821abe841dc307f78c1b47712361af68a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 12 Aug 2025 13:23:49 +0000 Subject: [PATCH 09/12] =?UTF-8?q?style:=20=F0=9F=8E=A8=20apply=20pre-commi?= =?UTF-8?q?t.ci=20formatting?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Automated formatting by clang-format, prettier, and other hooks. See https://pre-commit.ci for details. --- README.md | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 8abea5cdfe..fc676c83e5 100644 --- a/README.md +++ b/README.md @@ -29,13 +29,15 @@ SKSE core plugin for community-driven advanced graphics modifications. - Edit the `PATH` environment variable and add the Git.exe install path as a new value ## Optional Requirements + ``` -CMake & Vcpkg comes with Visual Studio in Developer Command Prompts already. +CMake & Vcpkg comes with Visual Studio in Developer Command Prompts already. Install them manually only if you want them in everywhere. ``` + - [CMake](https://cmake.org/) - No need to install manually if you have Visual Studio CMake Tools installed - - CMake 4.0+ is __not__ supported right now + - CMake 4.0+ is **not** supported right now - Edit the `PATH` environment variable and add the cmake.exe install path as a new value - Instructions for finding and editing the `PATH` environment variable can be found [here](https://www.java.com/en/download/help/path.html) - [Vcpkg](https://github.com/microsoft/vcpkg) @@ -163,11 +165,14 @@ docker run -it --rm --isolation=process -v .:C:/skyrim-community-shaders skyrim- ``` ## Debugging + ### Launching MO2-SKSE-Skyrim from commandline + 1. Open Steam 2. Close ModOrganizer GUI 3. Add `ModOrganizer.exe` (MO2 Folder) to your PATH, or use the path of it 4. Run the commands: + ```pwsh # Change Working Directory cd "C:/Program Files (x86)/Steam/steamapps/common/Skyrim Special Edition" @@ -176,11 +181,13 @@ ModOrganizer.exe --log run "C:\Program Files (x86)\Steam\steamapps\common\Skyrim ``` ### Capture with RenderDoc + In Launch Application Menu, use the following settings: -- Executable Path: `PATH/TO/ModOrganizer.exe` -- Working Directory: `C:/Program Files (x86)/Steam/steamapps/common/Skyrim Special Edition` -- Command-line Arguments: `--log run "C:\Program Files (x86)\Steam\steamapps\common\Skyrim Special Edition\skse64_loader.exe"` -- [x] __Capture Child Process__ + +- Executable Path: `PATH/TO/ModOrganizer.exe` +- Working Directory: `C:/Program Files (x86)/Steam/steamapps/common/Skyrim Special Edition` +- Command-line Arguments: `--log run "C:\Program Files (x86)\Steam\steamapps\common\Skyrim Special Edition\skse64_loader.exe"` +- [x] **Capture Child Process** ## License From 87bfaf9d626dea7db8ab57320a1602454d325668 Mon Sep 17 00:00:00 2001 From: Alan Tse Date: Mon, 3 Nov 2025 01:21:22 -0800 Subject: [PATCH 10/12] build: make AIO archive incremental (stamp file) Create a stable stamp file for the automatic AIO archive so CMake only rebuilds the archive when inputs change. The AIO tar step now writes ${CMAKE_CURRENT_BINARY_DIR}/aio_package.stamp and `AIO_ZIP_PACKAGE` depends on that stamp while preserving the UTC timestamp in the archive filename. --- .claude/CLAUDE.md | 102 ++++++++++++++++++++++++++++++++++++++++----- AI-INSTRUCTIONS.md | 20 +++++++++ CMakeLists.txt | 63 ++++++++++++++++++++-------- CMakePresets.json | 4 +- README.md | 18 +++++--- 5 files changed, 171 insertions(+), 36 deletions(-) diff --git a/.claude/CLAUDE.md b/.claude/CLAUDE.md index d6f2036ee9..223bd4b9f1 100644 --- a/.claude/CLAUDE.md +++ b/.claude/CLAUDE.md @@ -21,22 +21,38 @@ powershell.exe -Command "./BuildRelease.bat [PRESET_NAME]" **Available Presets** (from CMakePresets.json): -- `ALL` (default) - Builds for SE/AE/VR in single binary -- `SE` - Skyrim Special Edition only -- `AE` - Anniversary Edition only -- `VR` - Skyrim VR only -- `ALL-TRACY` - Includes Tracy profiler support -- `ALL-WITH-AUTO-DEPLOYMENT` - Auto-deploys to configured Skyrim directories when template used. +- `ALL` (default) - Builds universal binary supporting SE/AE/VR runtime detection +- `SE` - Skyrim Special Edition only (compile-time targeting) +- `AE` - Anniversary Edition only (compile-time targeting) +- `VR` - Skyrim VR only (compile-time targeting) +- `PRE-AE` - SE + VR (excludes AE) +- `FLATRIM` - SE + AE (excludes VR) +- `ALL-TRACY` - Universal binary with Tracy profiler support enabled + +**User Preset Template**: + +- `ALL-WITH-AUTO-DEPLOYMENT` - Extends `ALL` with `AUTO_PLUGIN_DEPLOYMENT=ON` (copy template to use) ### Development Setup 1. Copy `CMakeUserPresets.json.template` → `CMakeUserPresets.json` 2. Configure `CommunityShadersOutputDir` for auto-deployment to Skyrim installations -3. Set build options in user preset: - - `AUTO_PLUGIN_DEPLOYMENT`: Auto-copy to Skyrim dirs - - `AIO_ZIP_TO_DIST`: Creates all-in-one distribution package - - `ZIP_TO_DIST`: Creates individual feature packages - - `TRACY_SUPPORT`: Enables performance profiling +3. Set build options in user preset or CMake cache: + +**Build Options** (CMake cache variables): + +- `AUTO_PLUGIN_DEPLOYMENT` (default: OFF) - Auto-copy build output to `CommunityShadersOutputDir` +- `ZIP_TO_DIST` (default: ON) - Creates individual feature packages as 7z files in `/dist` +- `AIO_ZIP_TO_DIST` (default: ON) - Creates all-in-one distribution package as 7z in `/dist` +- `TRACY_SUPPORT` (default: OFF) - Enables Tracy profiler integration for performance analysis + +**Auto-Deployment Configuration**: + +Set `CommunityShadersOutputDir` environment variable to semicolon-separated Skyrim Data directories: + +``` +CommunityShadersOutputDir=F:/MySkyrimModpack/mods/CommunityShaders;F:/SteamLibrary/steamapps/common/SkyrimVR/Data;F:/SteamLibrary/steamapps/common/Skyrim Special Edition/Data +``` ### Shader Development and Testing @@ -73,8 +89,72 @@ hlslkit-generate-defines --log CommunityShaders.log hlslkit-buffer-scan --features-dir features/ ``` +### Custom CMake Targets + +**Package and Deployment Targets**: + +```bash +# Prepare AIO package structure (automatic with AIO_ZIP_TO_DIST or AUTO_PLUGIN_DEPLOYMENT) +cmake --build ./build/ALL --target PREPARE_AIO + +# Prepare shaders only (useful for CI shader validation) +cmake --build ./build/ALL --target prepare_shaders + +# Copy shaders to deployment directories (when AUTO_PLUGIN_DEPLOYMENT=ON) +cmake --build ./build/ALL --target COPY_SHADERS + +# Create AIO zip package (when AIO_ZIP_TO_DIST=ON) +cmake --build ./build/ALL --target AIO_ZIP_PACKAGE +``` + +**Development Targets**: + +```bash +# Format all C++ and HLSL code (requires clang-format) +cmake --build ./build/ALL --target FORMAT_CODE + +# Generate shader validation configs from game logs (requires PowerShell) +cmake --build ./build/ALL --target generate_shader_configs +``` + ## Architecture Overview +### Manual packaging targets (detailed) + +The project also provides a set of manual packaging targets that create distributable 7z packages or install the project into the AIO folder. These targets are useful when you want precise control over packaging (CI artifacts, local QA, or manual deployment). + +Quick commands: + +```bash +# Create the Core package (includes CORE features + plugin DLL) +cmake --build ./build/ALL --target Package-Core + +# Create a manual AIO package (.7z) via install + tar +cmake --build ./build/ALL --target Package-AIO-Manual + +# Create an individual feature package (name is sanitized from the feature folder) +cmake --build ./build/ALL --target Package- + +# Install into the AIO folder (installs to build//aio) +cmake --build ./build/ALL --target AIO + +# Alternatively use cmake --install to install to a custom prefix +cmake --install ./build/ALL --prefix # installs files according to CMake install() rules +``` + +Notes and behaviour: + +- `Package-Core` collects everything marked as CORE and the built plugin into a temporary folder, then tars it to `dist/${PROJECT_NAME}-${UTC_NOW}.7z`. +- `Package-` targets are generated per feature directory (non-CORE features). They create `${FEATURE}-${UTC_NOW}.7z` in `dist/`. +- `Package-AIO-Manual` performs an install to the AIO folder and then creates a single AIO archive. This is similar to the automated `AIO_ZIP_PACKAGE`, but wired as an explicit file-producing custom target (useful for CI reproducibility). +- `AIO` target runs `cmake --install` with the `aio` prefix so you can locally inspect the AIO folder layout without creating an archive. +- The install-based packaging uses the CMake `install()` rules defined near the top of `CMakeLists.txt` (the project installs `SKSE/Plugins`, copies `package/` and feature folders, and removes the Core placeholder). This makes manual installs and CI artifacts consistent with the runtime AIO layout. + +Where to look in `CMakeLists.txt`: + +- Manual packaging targets are defined in the "Manual packaging targets (Package-XXX)" section and create files under `${CMAKE_SOURCE_DIR}/dist`. +- The `install()` rules near the top of the file show what gets placed into the AIO layout when running `cmake --install`. + ### Plugin Architecture **Core Pattern**: Feature-driven modular system where each graphics enhancement is an independent `Feature` class that can be enabled/disabled at runtime. diff --git a/AI-INSTRUCTIONS.md b/AI-INSTRUCTIONS.md index 9c531bd233..56b9ddfe66 100644 --- a/AI-INSTRUCTIONS.md +++ b/AI-INSTRUCTIONS.md @@ -26,6 +26,26 @@ SKSE plugin providing advanced DirectX 11 graphics modifications for Skyrim SE/A - **Shader Test**: `hlslkit-compile --shader-dir [target]` (install via pip first) - **Feature Access**: `globals::features::*` namespace +### Build Options + +**Runtime Presets**: `ALL` (universal), `SE`, `AE`, `VR`, `PRE-AE`, `FLATRIM`, `ALL-TRACY` + +**CMake Options** (set in user preset): + +- `AUTO_PLUGIN_DEPLOYMENT=ON` - Auto-copy to `CommunityShadersOutputDir` +- `ZIP_TO_DIST=ON` (default) - Create individual feature 7z packages +- `AIO_ZIP_TO_DIST=ON` (default) - Create all-in-one 7z package +- `TRACY_SUPPORT=ON` - Enable Tracy profiler integration + +### Custom CMake Targets + +**Quick targets** (common): + +- `PREPARE_AIO`, `prepare_shaders`, `COPY_SHADERS`, `AIO_ZIP_PACKAGE` +- `FORMAT_CODE`, `generate_shader_configs` + +For full details about manual packaging targets (Package-Core, Package-AIO-Manual, Package-, AIO) and example workflows, see the "Manual packaging targets (detailed)" section in `.claude/CLAUDE.md` to avoid duplication. + ### AI Assistant Role **Act as an experienced graphics programming and Skyrim modding expert.** diff --git a/CMakeLists.txt b/CMakeLists.txt index 6d61da08dc..51e5108693 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,8 +2,11 @@ cmake_minimum_required(VERSION 3.21) cmake_policy(SET CMP0116 NEW) set(CMAKE_POLICY_WARNING_CMP0116 OFF) -if (CMAKE_VERSION VERSION_GREATER_EQUAL "4.0.0") - message(ERROR "EASTL will fail to install with vcpkg using cmake 4.0+, remove this line if the port get fixed.") +if(CMAKE_VERSION VERSION_GREATER_EQUAL "4.0.0") + message( + ERROR + "EASTL will fail to install with vcpkg using cmake 4.0+, remove this line if the port get fixed." + ) endif() project( @@ -15,7 +18,10 @@ project( # default install path if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) - set_property(CACHE CMAKE_INSTALL_PREFIX PROPERTY VALUE "${CMAKE_CURRENT_BINARY_DIR}/aio") + set_property( + CACHE CMAKE_INSTALL_PREFIX + PROPERTY VALUE "${CMAKE_CURRENT_BINARY_DIR}/aio" + ) endif() list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") @@ -270,8 +276,16 @@ list(TRANSFORM FEATURE_PATHS_SLASH APPEND /) # To copy AIO package at a folder do `${CMAKE_COMMAND} --install ${CMAKE_BINARY_DIR} --prefix ${AIO_DIR}` install(CODE "file(REMOVE_RECURSE \${CMAKE_INSTALL_PREFIX})") install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION SKSE/Plugins COMPONENT SKSE) -install(FILES $ DESTINATION SKSE/Plugins COMPONENT SKSE) -install(DIRECTORY ${CMAKE_SOURCE_DIR}/package/ ${FEATURE_PATHS_SLASH} DESTINATION . COMPONENT Shaders) +install( + FILES $ + DESTINATION SKSE/Plugins + COMPONENT SKSE +) +install( + DIRECTORY ${CMAKE_SOURCE_DIR}/package/ ${FEATURE_PATHS_SLASH} + DESTINATION . + COMPONENT Shaders +) install(CODE "file(REMOVE \${CMAKE_INSTALL_PREFIX}/Core)" COMPONENT Shaders) # ####################################################################################################################### @@ -693,17 +707,27 @@ if(AIO_ZIP_TO_DIST) ) endif() + # Create a stamp-producing custom command for the AIO archive so CMake + # only rebuilds the archive when its inputs change. The archive filename + # keeps the UTC timestamp as before, but the command writes a stable + # stamp file that CMake can track as OUTPUT. set(TARGET_AIO_ZIP "${PROJECT_NAME}_AIO-${UTC_NOW}.7z") - message("Zipping ${AIO_DIR} to ${CMAKE_SOURCE_DIR}/dist/${TARGET_AIO_ZIP}") - add_custom_target( - AIO_ZIP_PACKAGE - ALL - COMMAND - ${CMAKE_COMMAND} -E tar cf - ${CMAKE_SOURCE_DIR}/dist/${TARGET_AIO_ZIP} --format=7zip -- . + set(AIO_ARCHIVE "${CMAKE_SOURCE_DIR}/dist/${TARGET_AIO_ZIP}") + set(AIO_ZIP_STAMP "${CMAKE_CURRENT_BINARY_DIR}/aio_package.stamp") + + message("Zipping ${AIO_DIR} to ${AIO_ARCHIVE}") + + add_custom_command( + OUTPUT ${AIO_ZIP_STAMP} + COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_SOURCE_DIR}/dist" + COMMAND ${CMAKE_COMMAND} -E tar cf ${AIO_ARCHIVE} --format=7zip -- . + COMMAND ${CMAKE_COMMAND} -E touch ${AIO_ZIP_STAMP} WORKING_DIRECTORY ${AIO_DIR} DEPENDS PREPARE_AIO + COMMENT "Creating AIO archive ${AIO_ARCHIVE}" ) + + add_custom_target(AIO_ZIP_PACKAGE ALL DEPENDS ${AIO_ZIP_STAMP}) endif() if(NOT DEFINED ENV{CommunityShadersOutputDir}) @@ -722,7 +746,11 @@ file(MAKE_DIRECTORY "${CMAKE_SOURCE_DIR}/dist") set(CORE_PACKAGE "${DIST_PATH}/${PROJECT_NAME}-${UTC_NOW}.7z") # CORE_SOURCES = all content copied to the AIO directory + the SKSE plugin dll -file(GLOB_RECURSE CORE_SOURCES CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/package/*") +file( + GLOB_RECURSE CORE_SOURCES + CONFIGURE_DEPENDS + "${CMAKE_SOURCE_DIR}/package/*" +) # Add SKSE plugin dll as dependency list(APPEND CORE_SOURCES ${PROJECT_NAME}) @@ -745,10 +773,10 @@ add_custom_command( COMMAND ${CMAKE_COMMAND} --install ${CMAKE_BINARY_DIR} --prefix ${FEATURE_PATH} --component SKSE - COMMAND ${CMAKE_COMMAND} -E copy_directory ${CORE_FEATURE_PATHS} ${FEATURE_PATH} - COMMAND ${CMAKE_COMMAND} -E rm -f -- ${FEATURE_PATH}/Core COMMAND - ${CMAKE_COMMAND} -E tar cfv ${CORE_PACKAGE} --format=7zip -- . + ${CMAKE_COMMAND} -E copy_directory ${CORE_FEATURE_PATHS} ${FEATURE_PATH} + COMMAND ${CMAKE_COMMAND} -E rm -f -- ${FEATURE_PATH}/Core + COMMAND ${CMAKE_COMMAND} -E tar cfv ${CORE_PACKAGE} --format=7zip -- . WORKING_DIRECTORY ${FEATURE_PATH} COMMENT "Creating Core zip package" ) @@ -796,8 +824,7 @@ add_custom_command( OUTPUT ${AIO_PACKAGE} DEPENDS ${CORE_SOURCES} COMMAND ${CMAKE_COMMAND} --install ${CMAKE_BINARY_DIR} --prefix ${AIO_DIR} - COMMAND - ${CMAKE_COMMAND} -E tar cfv ${AIO_PACKAGE} --format=7zip -- . + COMMAND ${CMAKE_COMMAND} -E tar cfv ${AIO_PACKAGE} --format=7zip -- . WORKING_DIRECTORY ${AIO_DIR} COMMENT "Creating AIO zip package (manual)" ) diff --git a/CMakePresets.json b/CMakePresets.json index b30165bef5..1966d5f729 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -75,14 +75,14 @@ "description": "(Deprecated), kept for for CI, use Package instead", "configurePreset": "ALL", "configuration": "Release", - "targets": ["CommunityShaders", "Package-AIO"] + "targets": ["CommunityShaders", "Package-AIO-Manual"] }, { "name": "Package", "description": "Build preset to generate a AIO zip package in /dist folder, mostly for CI", "configurePreset": "ALL", "configuration": "Release", - "targets": ["CommunityShaders", "Package-AIO"] + "targets": ["CommunityShaders", "Package-AIO-Manual"] }, { "name": "Shaders", diff --git a/README.md b/README.md index fc676c83e5..1078cc5ff1 100644 --- a/README.md +++ b/README.md @@ -104,17 +104,25 @@ cmake --install ./build/ALL --prefix $MOD_FOLDER #### Build a zip package You can build zip packages for optional cmake targets. -Currently support `Package-AIO`, `Package-Core`, and `Package-`: +Currently support `AIO_ZIP_PACKAGE`, `Package-AIO-Manual`, `Package-Core`, and `Package-`: ```pwsh # Create a AIO package in ./dist/ -cmake --build ./build/ALL --config Release --target Package-AIO +# Automated AIO zip (requires AIO_ZIP_TO_DIST=ON) +cmake --build ./build/ALL --config Release --target AIO_ZIP_PACKAGE + +# Manual AIO package (install + tar) +cmake --build ./build/ALL --config Release --target Package-AIO-Manual + # Create a CommunityShaders core package in ./dist/ -cmake --build ./build/ALL --config Release --target Package-Core -# Create a feature package in ./dist/ -cmake --build ./build/ALL --config Release --target Package-GrassLighting +cmake --build ./build/ALL --config Release --target Package-Core + +# Create a feature package in ./dist/ (example: GrassLighting) +cmake --build ./build/ALL --config Release --target Package-GrassLighting ``` +For more details about packaging targets, options, and the difference between automated and manual packaging, see the "Manual packaging targets (detailed)" section in `.claude/CLAUDE.md`. + #### CMAKE Options (optional) If you want an example CMakeUserPreset to start off with you can copy the `CMakeUserPresets.json.template` -> `CMakeUserPresets.json` From aeb9424defb93170454bcf03630c6883c58cc276 Mon Sep 17 00:00:00 2001 From: Alan Tse Date: Mon, 3 Nov 2025 02:30:02 -0800 Subject: [PATCH 11/12] chore: address ai comments - Replace "\"${FEATURE_PATH}/\"" with "${FEATURE_PATH}/" so feature paths are normal strings during packaging. - Update README: prefer Developer PowerShell/x64 Native Tools prompt; use presets where appropriate and fix typos. --- CMakeLists.txt | 4 ++-- README.md | 30 +++++++++++++----------------- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 51e5108693..ab9f548d43 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -758,7 +758,7 @@ set(CORE_FEATURE_PATHS "${CMAKE_SOURCE_DIR}/package/") foreach(FEATURE_PATH ${FEATURE_PATHS}) if(EXISTS "${FEATURE_PATH}/CORE") - list(APPEND CORE_FEATURE_PATHS "\"${FEATURE_PATH}/\"") + list(APPEND CORE_FEATURE_PATHS "${FEATURE_PATH}/") file(GLOB_RECURSE FEATURE_SOURCES CONFIGURE_DEPENDS "${FEATURE_PATH}/*") list(APPEND CORE_SOURCES ${FEATURE_SOURCES}) endif() @@ -788,7 +788,7 @@ foreach(FEATURE_PATH ${FEATURE_PATHS}) continue() endif() - list(APPEND CORE_FEATURE_PATHS "\"${FEATURE_PATH}/\"") + list(APPEND CORE_FEATURE_PATHS "${FEATURE_PATH}/") file(GLOB_RECURSE FEATURE_SOURCES CONFIGURE_DEPENDS "${FEATURE_PATH}/*") list(APPEND CORE_SOURCES ${FEATURE_SOURCES}) diff --git a/README.md b/README.md index 1078cc5ff1..2e99b79750 100644 --- a/README.md +++ b/README.md @@ -77,29 +77,25 @@ Right click on the target and select `Build` to create the zip package in `./dis ### Advanced build with CMake in command line -In Windows Start menu, search for `x64 Native Tools Command Prompt`, open it in a Cmd or Powershell terminal: +Open the "Developer PowerShell for VS 2022" or the "x64 Native Tools Command Prompt" (these set up the Visual Studio toolchain for you). -```pwsh -# Same as running `x64 Native Tools Command Prompt` -# Adding cl.exe and cmake.exe into your PATH -& "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" amd64 +Then from the repository root run: -# Change to the repository folder -cd skyrim-community-shaders +```pwsh +# Generate the build files (uses the ALL preset) +cmake --preset ALL -# Generate the build files in ./build/ALL -cmake -S . --preset=ALL -B ./build/ALL +# Build using the preset +cmake --build --preset ALL -# Invoke build tool to build the C++ source code -# This also generate an AIO folder in ./build/ALL/aio -cmake --build ./build/ALL --preset ALL +# Install an AIO package somewhere, e.g. $MOD_FOLDER +cmake --install --preset ALL -- --prefix $MOD_FOLDER +``` -# The cmake & cmake --build comamnd are captured in this batch file as well -# ./BuildRelease.bat +# Notes -# Install an AIO package into anywhere, e.g. $MOD_FOLDER -cmake --install ./build/ALL --prefix $MOD_FOLDER -``` +- If you prefer to run the VC environment manually, launch Developer PowerShell or the x64 Native Tools prompt instead of calling vcvarsall.bat directly from PowerShell. +- The convenience wrapper `BuildRelease.bat` also captures these steps. #### Build a zip package From 06ec8a2e5b8bba93a26aeb320aa6f642161faa05 Mon Sep 17 00:00:00 2001 From: Alan Tse Date: Mon, 3 Nov 2025 02:40:00 -0800 Subject: [PATCH 12/12] build: use target-file generator expression - Replace literal project name in CORE_SOURCES with "$" so add_custom_command DEPENDS references the actual DLL path at build time. --- CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ab9f548d43..70e8c1cd67 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -751,8 +751,9 @@ file( CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/package/*" ) -# Add SKSE plugin dll as dependency -list(APPEND CORE_SOURCES ${PROJECT_NAME}) +# Add SKSE plugin dll as dependency (use target-file generator expression so CMake +# knows the actual output path of the target at build time) +list(APPEND CORE_SOURCES "$") set(CORE_FEATURE_PATHS "${CMAKE_SOURCE_DIR}/package/")