ship CMakePresets.json instead of copying a template

Co-Authored-By: Grok 4.6 <noreply@x.ai>
This commit is contained in:
Marco Antonio J. Costa
2026-08-20 15:15:10 -03:00
committed by majcosta
co-authored by Grok 4.6
parent c9100aacee
commit 69764e4459
7 changed files with 65 additions and 61 deletions
-2
View File
@@ -123,8 +123,6 @@ jobs:
run: |
set -eux
touch CMakePresets.json
JA2Application=$(echo '${{ matrix.application }}' | tr '[:lower:]' '[:upper:]')
echo "
+1 -1
View File
@@ -6,6 +6,6 @@
/.vs/
/build/
/out/
/CMakePresets.json
/CMakeUserPresets.json
/CMakeSettings.json
/lib/
-3
View File
@@ -18,9 +18,6 @@ if(USE_SCCACHE)
endif()
endif()
include(cmake/CopyUserPresetTemplate.cmake)
CopyUserPresetTemplate()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
+61
View File
@@ -0,0 +1,61 @@
{
"version": 3,
"cmakeMinimumRequired": {
"major": 3,
"minor": 20,
"patch": 0
},
"configurePresets": [
{
"name": "base",
"hidden": true,
"description": "Applications is JA2|JA2MAPEDITOR|JA2UB|JA2UBMAPEDITOR|empty(all 4); override CMAKE_RUNTIME_OUTPUT_DIRECTORY in CMakeUserPresets.json to debug another install.",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build/${presetName}",
"architecture": {
"value": "x86",
"strategy": "external"
},
"cacheVariables": {
"CMAKE_RUNTIME_OUTPUT_DIRECTORY": "${sourceDir}/gamedir"
}
},
{
"name": "msvc",
"hidden": true,
"inherits": "base",
"vendor": {
"microsoft.com/VisualStudioSettings/CMake/1.0": {
"hostOS": [ "Windows" ],
"intelliSenseMode": "windows-msvc-x86"
}
}
},
{
"name": "msvc-relwithdebinfo",
"inherits": "msvc",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
}
},
{
"name": "msvc-debug",
"inherits": "msvc",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "msvc-release",
"inherits": "msvc",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
}
],
"buildPresets": [
{ "name": "msvc-relwithdebinfo", "configurePreset": "msvc-relwithdebinfo" },
{ "name": "msvc-debug", "configurePreset": "msvc-debug" },
{ "name": "msvc-release", "configurePreset": "msvc-release" }
]
}
+3 -4
View File
@@ -65,10 +65,9 @@ Visit the [releases page](https://github.com/1dot13/source/releases) to download
* Double-click on `Folder View` in the `Solution Explorer`
* Click `Open a local folder`
* Use this option if you already cloned the repository yourself.
3. Visual Studio will automatically detect the CMake configuration files and will run the CMake generation. There will bet a CMake error in the logs saying `No existing preset was found, copied a preset template to [some_path]`. This is normal and only happens once.
4. Click on the dropdown that says `x64-Debug` and select `Manage configurations...`. This should trigger Visual Studio to load the `CMakeUserPresets.json` file it just copied. Now you can close the window for managing the configurations.
5. The `x64-Debug` option should have been replaced by `1dot13 Debug`. Click it and select `Manage configurations...` again. Here is where you configure the language for the built executables as well as which ones to build, Most important, here is where you set `CMAKE_RUNTIME_OUTPUT_DIRECTORY` to the path to your JA2 1.13 installation. This will be used for debugging. Note that the path needs to have a working 1.13 installation, and that includes the 1.13 game data.
6. You can use `Build -> Build All` to build the executables you selected in the configuration.
3. Visual Studio detects `CMakePresets.json` and lists the `msvc-*` configurations. Executables are written to `gamedir/`.
4. To build only some applications, or to debug against a different JA2 1.13 install, add/modify a `CMakeUserPresets.json` in the source root that inherits one of the shipped presets and sets the `Applications` and/or `CMAKE_RUNTIME_OUTPUT_DIRECTORY` `cacheVariables`. Language is chosen at runtime, not at configure time.
5. Use `Build -> Build All` to build.
### Reports
-10
View File
@@ -1,10 +0,0 @@
function(CopyUserPresetTemplate)
if(
NOT DEFINED Applications AND
NOT EXISTS "${CMAKE_SOURCE_DIR}/CMakePresets.json" AND
NOT EXISTS "${CMAKE_SOURCE_DIR}/CMakeUserPresets.json"
)
file(COPY "${CMAKE_SOURCE_DIR}/cmake/presets/CMakePresets.json" DESTINATION "${CMAKE_SOURCE_DIR}")
message(FATAL_ERROR "No existing preset was found, copied a preset template to ${CMAKE_SOURCE_DIR}/CMakePresets.json.")
endif()
endfunction()
-41
View File
@@ -1,41 +0,0 @@
{
"version": 3,
"configurePresets": [
{
"name": "__userBase",
"hidden": true,
"description": "Applications takes any of JA2, JA2MAPEDITOR, JA2UB, JA2UBMAPEDITOR, and builds all four when empty. Set CMAKE_RUNTIME_OUTPUT_DIRECTORY to a gamedir, e.g. C:/Games/JA2, to put the executables where they can be debugged.",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build/${presetName}",
"cacheVariables": {
"Applications": "JA2",
"CMAKE_RUNTIME_OUTPUT_DIRECTORY": "."
},
"architecture": {
"value": "x86",
"strategy": "external"
}
},
{
"name": "1dot13 RelWithDebInfo",
"inherits": "__userBase",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
}
},
{
"name": "1dot13 Release",
"inherits": "__userBase",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "1dot13 Debug",
"inherits": "__userBase",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
}
]
}