From cec66bb5c724904cb44554aca4e4c3b416da6175 Mon Sep 17 00:00:00 2001 From: Eddoursul Date: Thu, 30 Jul 2026 13:13:16 +0200 Subject: [PATCH] Re-added .cmake as text --- .gitattributes | 2 + .../Enderal DLL/cmake/patch_directxtk.cmake | 23 ++++ source/Enderal DLL/cmake/version.rc.in | 34 +++++ .../cmake/write_user_presets.cmake | 116 ++++++++++++++++++ source/Steam DLL/cmake/patch_directxtk.cmake | 23 ++++ source/Steam DLL/cmake/version.rc.in | 34 +++++ .../Steam DLL/cmake/write_user_presets.cmake | 116 ++++++++++++++++++ 7 files changed, 348 insertions(+) create mode 100644 source/Enderal DLL/cmake/patch_directxtk.cmake create mode 100644 source/Enderal DLL/cmake/version.rc.in create mode 100644 source/Enderal DLL/cmake/write_user_presets.cmake create mode 100644 source/Steam DLL/cmake/patch_directxtk.cmake create mode 100644 source/Steam DLL/cmake/version.rc.in create mode 100644 source/Steam DLL/cmake/write_user_presets.cmake diff --git a/.gitattributes b/.gitattributes index d213efba6..3e66c4265 100644 --- a/.gitattributes +++ b/.gitattributes @@ -8,8 +8,10 @@ *.strings filter= diff= merge= -text *.gitignore filter= diff= merge= text eol=lf *.gitattributes filter= diff= merge= text eol=lf +*.cmake filter= diff= merge= text eol=lf *.xml filter= diff= merge= text eol=lf *.json filter= diff= merge= text eol=lf +*.in filter= diff= merge= text eol=crlf *.md filter= diff= merge= text eol=crlf *.ini filter= diff= merge= text eol=crlf *.txt filter= diff= merge= text eol=crlf diff --git a/source/Enderal DLL/cmake/patch_directxtk.cmake b/source/Enderal DLL/cmake/patch_directxtk.cmake new file mode 100644 index 000000000..8ac20ec2d --- /dev/null +++ b/source/Enderal DLL/cmake/patch_directxtk.cmake @@ -0,0 +1,23 @@ +# Patch applied to DirectXTK's CMakeLists.txt via FetchContent PATCH_COMMAND. +# +# DirectXTK compiles its HLSL shaders by running Src/Shaders/CompileShaders.cmd +# through `cmake -E env ... CompileShaders.cmd` (a bare script name, relying on +# the custom command's WORKING_DIRECTORY). Modern CMake no longer resolves a +# bare command name against the working directory, so the step fails with +# "no such file or directory" and the whole build stops. +# +# Rewrite that single invocation to an absolute path. WORKING_DIRECTORY is left +# untouched so the script still runs with Src/Shaders as its CWD. The replace is +# idempotent: after patching, the original "CompileShaders.cmd ARGS" substring is +# gone, so re-running the patch is a no-op. It also targets only the COMMAND line +# (the MAIN_DEPENDENCY reference already uses a full path and is not matched). +set(_dxtk_cmakelists "CMakeLists.txt") + +file(READ "${_dxtk_cmakelists}" _dxtk_content) +string(REPLACE + "CompileShaders.cmd ARGS" + "\"\${PROJECT_SOURCE_DIR}/Src/Shaders/CompileShaders.cmd\" ARGS" + _dxtk_content "${_dxtk_content}") +file(WRITE "${_dxtk_cmakelists}" "${_dxtk_content}") + +message(STATUS "Patched DirectXTK CompileShaders.cmd invocation to use an absolute path.") diff --git a/source/Enderal DLL/cmake/version.rc.in b/source/Enderal DLL/cmake/version.rc.in new file mode 100644 index 000000000..1e9766793 --- /dev/null +++ b/source/Enderal DLL/cmake/version.rc.in @@ -0,0 +1,34 @@ +#include + +1 VERSIONINFO + FILEVERSION @PROJECT_VERSION_MAJOR@, @PROJECT_VERSION_MINOR@, @PROJECT_VERSION_PATCH@, @PROJECT_VERSION_TWEAK@ + PRODUCTVERSION @PROJECT_VERSION_MAJOR@, @PROJECT_VERSION_MINOR@, @PROJECT_VERSION_PATCH@, @PROJECT_VERSION_TWEAK@ + FILEFLAGSMASK 0x17L +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "CompanyName", "Eddoursul (mod.pub)" + VALUE "FileDescription", "@PROJECT_DESCRIPTION@" + VALUE "FileVersion", "@PROJECT_VERSION@" + VALUE "InternalName", "@PROJECT_NAME@" + VALUE "LegalCopyright", "The GNU General Public License v3.0" + VALUE "ProductName", "@PROJECT_FRIENDLY_NAME@" + VALUE "ProductVersion", "@PROJECT_VERSION@" + VALUE "OriginalFilename", "@PROJECT_NAME@.dll" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END diff --git a/source/Enderal DLL/cmake/write_user_presets.cmake b/source/Enderal DLL/cmake/write_user_presets.cmake new file mode 100644 index 000000000..2b415834a --- /dev/null +++ b/source/Enderal DLL/cmake/write_user_presets.cmake @@ -0,0 +1,116 @@ +# Generates CMakeUserPresets.json, pinning "cmakeExecutable" to the CMake that is +# running this script - i.e. the one build.cmd itself uses. +# +# Why: both drivers share one binaryDir per configuration, so build.cmd and Visual +# Studio write the same Ninja tree. Visual Studio otherwise uses its own bundled +# CMake, and two CMake versions generating one tree emit different compile command +# lines, which makes Ninja rebuild everything on every switch. See CLAUDE.md. +# +# Why generated rather than committed: Visual Studio resolves "cmakeExecutable" +# against the current directory only - a bare "cmake" is not looked up on PATH - so +# the value must be an absolute path, which is machine-specific and cannot live in +# the committed CMakePresets.json. +# +# Run as: cmake -P cmake/write_user_presets.cmake + +cmake_minimum_required(VERSION 3.21) + +# Marks the file as ours, so a hand-written one is never clobbered. +set(GENERATED_MARKER "local-cmake") + +set(TEMPLATE [==[ +{ + "version": 2, + "configurePresets": [ + { + "name": "local-cmake", + "hidden": true, + "cmakeExecutable": "@CMAKE_COMMAND@" + }, + { + "name": "build-release-msvc-local", + "inherits": [ + "local-cmake", + "build-release-msvc" + ], + "displayName": "Release (MSVC) [local CMake]", + "description": "Select this in Visual Studio: same build tree as build.cmd, pinned to the same CMake. Generated by build.cmd - do not edit." + }, + { + "name": "build-debug-msvc-local", + "inherits": [ + "local-cmake", + "build-debug-msvc" + ], + "displayName": "Debug (MSVC) [local CMake]", + "description": "Select this in Visual Studio: same build tree as build.cmd, pinned to the same CMake. Generated by build.cmd - do not edit." + }, + { + "name": "build-release-clang-cl-local", + "inherits": [ + "local-cmake", + "build-release-clang-cl" + ], + "displayName": "Release (Clang) [local CMake]", + "description": "Select this in Visual Studio: same build tree as build.cmd, pinned to the same CMake. Generated by build.cmd - do not edit." + }, + { + "name": "build-debug-clang-cl-local", + "inherits": [ + "local-cmake", + "build-debug-clang-cl" + ], + "displayName": "Debug (Clang) [local CMake]", + "description": "Select this in Visual Studio: same build tree as build.cmd, pinned to the same CMake. Generated by build.cmd - do not edit." + } + ], + "buildPresets": [ + { + "name": "release-msvc-local", + "configurePreset": "build-release-msvc-local", + "displayName": "Release (MSVC) [local CMake]" + }, + { + "name": "debug-msvc-local", + "configurePreset": "build-debug-msvc-local", + "displayName": "Debug (MSVC) [local CMake]" + }, + { + "name": "release-clang-cl-local", + "configurePreset": "build-release-clang-cl-local", + "displayName": "Release (Clang) [local CMake]" + }, + { + "name": "debug-clang-cl-local", + "configurePreset": "build-debug-clang-cl-local", + "displayName": "Debug (Clang) [local CMake]" + } + ] +} +]==]) + +string(CONFIGURE "${TEMPLATE}" CONTENT @ONLY) + +get_filename_component(OUTPUT_FILE "${CMAKE_CURRENT_LIST_DIR}/../CMakeUserPresets.json" ABSOLUTE) + +if(EXISTS "${OUTPUT_FILE}") + file(READ "${OUTPUT_FILE}" EXISTING) + + # Unchanged: leave the timestamp alone, or Visual Studio reloads the presets + # after every command-line build. + if(EXISTING STREQUAL CONTENT) + return() + endif() + + string(FIND "${EXISTING}" "\"${GENERATED_MARKER}\"" MARKER_POS) + if(MARKER_POS EQUAL -1) + message(WARNING + "CMakeUserPresets.json was not generated by build.cmd - leaving it untouched.\n" + "Delete it to let build.cmd manage it, or add \"cmakeExecutable\": \"${CMAKE_COMMAND}\" to it yourself." + ) + return() + endif() +endif() + +file(WRITE "${OUTPUT_FILE}" "${CONTENT}") +message(STATUS "Wrote CMakeUserPresets.json (cmakeExecutable: ${CMAKE_COMMAND})") diff --git a/source/Steam DLL/cmake/patch_directxtk.cmake b/source/Steam DLL/cmake/patch_directxtk.cmake new file mode 100644 index 000000000..8ac20ec2d --- /dev/null +++ b/source/Steam DLL/cmake/patch_directxtk.cmake @@ -0,0 +1,23 @@ +# Patch applied to DirectXTK's CMakeLists.txt via FetchContent PATCH_COMMAND. +# +# DirectXTK compiles its HLSL shaders by running Src/Shaders/CompileShaders.cmd +# through `cmake -E env ... CompileShaders.cmd` (a bare script name, relying on +# the custom command's WORKING_DIRECTORY). Modern CMake no longer resolves a +# bare command name against the working directory, so the step fails with +# "no such file or directory" and the whole build stops. +# +# Rewrite that single invocation to an absolute path. WORKING_DIRECTORY is left +# untouched so the script still runs with Src/Shaders as its CWD. The replace is +# idempotent: after patching, the original "CompileShaders.cmd ARGS" substring is +# gone, so re-running the patch is a no-op. It also targets only the COMMAND line +# (the MAIN_DEPENDENCY reference already uses a full path and is not matched). +set(_dxtk_cmakelists "CMakeLists.txt") + +file(READ "${_dxtk_cmakelists}" _dxtk_content) +string(REPLACE + "CompileShaders.cmd ARGS" + "\"\${PROJECT_SOURCE_DIR}/Src/Shaders/CompileShaders.cmd\" ARGS" + _dxtk_content "${_dxtk_content}") +file(WRITE "${_dxtk_cmakelists}" "${_dxtk_content}") + +message(STATUS "Patched DirectXTK CompileShaders.cmd invocation to use an absolute path.") diff --git a/source/Steam DLL/cmake/version.rc.in b/source/Steam DLL/cmake/version.rc.in new file mode 100644 index 000000000..12c0e9c48 --- /dev/null +++ b/source/Steam DLL/cmake/version.rc.in @@ -0,0 +1,34 @@ +#include + +1 VERSIONINFO + FILEVERSION @PROJECT_VERSION_MAJOR@, @PROJECT_VERSION_MINOR@, @PROJECT_VERSION_PATCH@, @PROJECT_VERSION_TWEAK@ + PRODUCTVERSION @PROJECT_VERSION_MAJOR@, @PROJECT_VERSION_MINOR@, @PROJECT_VERSION_PATCH@, @PROJECT_VERSION_TWEAK@ + FILEFLAGSMASK 0x17L +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x1L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "CompanyName", "SureAI, Eddoursul (mod.pub)" + VALUE "FileDescription", "@PROJECT_DESCRIPTION@" + VALUE "FileVersion", "@PROJECT_VERSION@" + VALUE "InternalName", "@PROJECT_NAME@" + VALUE "LegalCopyright", "GNU Lesser General Public License 3.0" + VALUE "ProductName", "@PROJECT_FRIENDLY_NAME@" + VALUE "ProductVersion", "@PROJECT_VERSION@" + VALUE "OriginalFilename", "@PROJECT_NAME@.dll" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END diff --git a/source/Steam DLL/cmake/write_user_presets.cmake b/source/Steam DLL/cmake/write_user_presets.cmake new file mode 100644 index 000000000..2b415834a --- /dev/null +++ b/source/Steam DLL/cmake/write_user_presets.cmake @@ -0,0 +1,116 @@ +# Generates CMakeUserPresets.json, pinning "cmakeExecutable" to the CMake that is +# running this script - i.e. the one build.cmd itself uses. +# +# Why: both drivers share one binaryDir per configuration, so build.cmd and Visual +# Studio write the same Ninja tree. Visual Studio otherwise uses its own bundled +# CMake, and two CMake versions generating one tree emit different compile command +# lines, which makes Ninja rebuild everything on every switch. See CLAUDE.md. +# +# Why generated rather than committed: Visual Studio resolves "cmakeExecutable" +# against the current directory only - a bare "cmake" is not looked up on PATH - so +# the value must be an absolute path, which is machine-specific and cannot live in +# the committed CMakePresets.json. +# +# Run as: cmake -P cmake/write_user_presets.cmake + +cmake_minimum_required(VERSION 3.21) + +# Marks the file as ours, so a hand-written one is never clobbered. +set(GENERATED_MARKER "local-cmake") + +set(TEMPLATE [==[ +{ + "version": 2, + "configurePresets": [ + { + "name": "local-cmake", + "hidden": true, + "cmakeExecutable": "@CMAKE_COMMAND@" + }, + { + "name": "build-release-msvc-local", + "inherits": [ + "local-cmake", + "build-release-msvc" + ], + "displayName": "Release (MSVC) [local CMake]", + "description": "Select this in Visual Studio: same build tree as build.cmd, pinned to the same CMake. Generated by build.cmd - do not edit." + }, + { + "name": "build-debug-msvc-local", + "inherits": [ + "local-cmake", + "build-debug-msvc" + ], + "displayName": "Debug (MSVC) [local CMake]", + "description": "Select this in Visual Studio: same build tree as build.cmd, pinned to the same CMake. Generated by build.cmd - do not edit." + }, + { + "name": "build-release-clang-cl-local", + "inherits": [ + "local-cmake", + "build-release-clang-cl" + ], + "displayName": "Release (Clang) [local CMake]", + "description": "Select this in Visual Studio: same build tree as build.cmd, pinned to the same CMake. Generated by build.cmd - do not edit." + }, + { + "name": "build-debug-clang-cl-local", + "inherits": [ + "local-cmake", + "build-debug-clang-cl" + ], + "displayName": "Debug (Clang) [local CMake]", + "description": "Select this in Visual Studio: same build tree as build.cmd, pinned to the same CMake. Generated by build.cmd - do not edit." + } + ], + "buildPresets": [ + { + "name": "release-msvc-local", + "configurePreset": "build-release-msvc-local", + "displayName": "Release (MSVC) [local CMake]" + }, + { + "name": "debug-msvc-local", + "configurePreset": "build-debug-msvc-local", + "displayName": "Debug (MSVC) [local CMake]" + }, + { + "name": "release-clang-cl-local", + "configurePreset": "build-release-clang-cl-local", + "displayName": "Release (Clang) [local CMake]" + }, + { + "name": "debug-clang-cl-local", + "configurePreset": "build-debug-clang-cl-local", + "displayName": "Debug (Clang) [local CMake]" + } + ] +} +]==]) + +string(CONFIGURE "${TEMPLATE}" CONTENT @ONLY) + +get_filename_component(OUTPUT_FILE "${CMAKE_CURRENT_LIST_DIR}/../CMakeUserPresets.json" ABSOLUTE) + +if(EXISTS "${OUTPUT_FILE}") + file(READ "${OUTPUT_FILE}" EXISTING) + + # Unchanged: leave the timestamp alone, or Visual Studio reloads the presets + # after every command-line build. + if(EXISTING STREQUAL CONTENT) + return() + endif() + + string(FIND "${EXISTING}" "\"${GENERATED_MARKER}\"" MARKER_POS) + if(MARKER_POS EQUAL -1) + message(WARNING + "CMakeUserPresets.json was not generated by build.cmd - leaving it untouched.\n" + "Delete it to let build.cmd manage it, or add \"cmakeExecutable\": \"${CMAKE_COMMAND}\" to it yourself." + ) + return() + endif() +endif() + +file(WRITE "${OUTPUT_FILE}" "${CONTENT}") +message(STATUS "Wrote CMakeUserPresets.json (cmakeExecutable: ${CMAKE_COMMAND})")