Re-added .cmake as text

This commit is contained in:
Eddoursul 2026-07-30 13:13:16 +02:00
parent 7d13d3d171
commit cec66bb5c7
7 changed files with 348 additions and 0 deletions

2
.gitattributes vendored
View File

@ -8,8 +8,10 @@
*.strings filter= diff= merge= -text *.strings filter= diff= merge= -text
*.gitignore filter= diff= merge= text eol=lf *.gitignore filter= diff= merge= text eol=lf
*.gitattributes 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 *.xml filter= diff= merge= text eol=lf
*.json 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 *.md filter= diff= merge= text eol=crlf
*.ini filter= diff= merge= text eol=crlf *.ini filter= diff= merge= text eol=crlf
*.txt filter= diff= merge= text eol=crlf *.txt filter= diff= merge= text eol=crlf

View File

@ -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.")

View File

@ -0,0 +1,34 @@
#include <winres.h>
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

View File

@ -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})")

View File

@ -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.")

View File

@ -0,0 +1,34 @@
#include <winres.h>
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

View File

@ -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})")