Switch from CMakeSettings to CMakePresets

This commit is contained in:
obligaron authored and Stephen C. Wills committed 2026-10-25 11:30:51 -04:00
1 parent 5ea9914c5e
commit 9d4871587e
6 files changed
+308 -266

No files matched your search

+23 -15
View File
@@ -18,6 +18,7 @@ permissions:
env:
VCPKG_FEATURE_FLAGS: dependencygraph
VCPKG_BINARY_SOURCES: "clear;files,${{ github.workspace }}/vcpkg_cache,readwrite"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
concurrency:
@@ -36,6 +37,14 @@ jobs:
- name: ccache
uses: hendrikmuhs/[email protected]
- name: cache vcpkg binary cache
uses: actions/cache@v6
with:
path: ${{ github.workspace }}/vcpkg_cache
key: ${{ runner.os }}-vcpkg-msvc-x64-${{ hashFiles('vcpkg.json', 'CMakePresets.json', '**/CMakeLists.txt') }}
restore-keys: |
${{ runner.os }}-vcpkg-msvc-x64-
- name: Install latest CMake
uses: lukka/get-cmake@latest
@@ -46,18 +55,15 @@ jobs:
- name: Fetch test data
run: |
mkdir build-ninja-vcpkg-relwithdebinfo
Invoke-WebRequest -Uri "https://github.com/diasurgical/devilutionx-assets/releases/download/v2/spawn.mpq" -OutFile "build-ninja-vcpkg-relwithdebinfo/spawn.mpq" -Resume
- name: Get CMakePresets.json
run: cp Packaging/windows/CMakePresets.json .
New-Item -ItemType Directory -Force -Path "build/msvc-x64-RelWithDebInfo"
Invoke-WebRequest -Uri "https://github.com/diasurgical/devilutionx-assets/releases/download/v2/spawn.mpq" -OutFile "build/msvc-x64-RelWithDebInfo/spawn.mpq" -Resume
- name: Run CMake consuming CMakePresets.json and vcpkg.json by mean of vcpkg.
uses: lukka/run-cmake@v10
with:
configurePreset: 'ninja-vcpkg-relwithdebinfo'
buildPreset: 'ninja-vcpkg-relwithdebinfo'
testPreset: 'ninja-vcpkg-relwithdebinfo'
configurePreset: 'msvc-x64-RelWithDebInfo'
buildPreset: 'msvc-x64-RelWithDebInfo'
testPreset: 'msvc-x64-RelWithDebInfo'
- name: Upload-Package
if: ${{ !env.ACT }}
@@ -65,10 +71,12 @@ jobs:
with:
name: devilutionx.exe
path: |
build-ninja-vcpkg-relwithdebinfo/devilutionx.exe
build-ninja-vcpkg-relwithdebinfo/bz2.dll
build-ninja-vcpkg-relwithdebinfo/libpng16.dll
build-ninja-vcpkg-relwithdebinfo/libsodium.dll
build-ninja-vcpkg-relwithdebinfo/SDL2.dll
build-ninja-vcpkg-relwithdebinfo/SDL2_image.dll
build-ninja-vcpkg-relwithdebinfo/zlib1.dll
build/msvc-x64-RelWithDebInfo/devilutionx.exe
build/msvc-x64-RelWithDebInfo/bz2.dll
build/msvc-x64-RelWithDebInfo/discord_game_sdk.dll
build/msvc-x64-RelWithDebInfo/libpng16.dll
build/msvc-x64-RelWithDebInfo/libsodium.dll
build/msvc-x64-RelWithDebInfo/lua.dll
build/msvc-x64-RelWithDebInfo/SDL2.dll
build/msvc-x64-RelWithDebInfo/SDL2_image.dll
build/msvc-x64-RelWithDebInfo/z.dll
+2
View File
@@ -18,6 +18,8 @@ add_definitions(-DWINVER=0x0601 -D_WIN32_WINDOWS=0x0601 -D_WIN32_WINNT=0x0601)
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
list(APPEND DEVILUTIONX_PLATFORM_COMPILE_OPTIONS "/W3" "/Zc:__cplusplus" "/utf-8")
list(APPEND DEVILUTIONX_PLATFORM_COMPILE_DEFINITIONS _CRT_SECURE_NO_WARNINGS)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
list(APPEND DEVILUTIONX_PLATFORM_COMPILE_DEFINITIONS _CRT_SECURE_NO_WARNINGS)
else()
list(APPEND DEVILUTIONX_PLATFORM_COMPILE_OPTIONS $<$<CONFIG:Debug>:-gstabs>)
endif()
+270
View File
@@ -0,0 +1,270 @@
{
"version": 5,
"configurePresets": [
{
"name": "base",
"hidden": true,
"generator": "Ninja",
"binaryDir": "${sourceDir}/build/${presetName}",
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": {
"type": "FILEPATH",
"value": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
},
"DISCORD_INTEGRATION": {
"type": "BOOL",
"value": "ON"
}
}
},
{
"name": "msvc-x64-base",
"hidden": true,
"inherits": "base",
"architecture": {
"value": "x64",
"strategy": "external"
}
},
{
"name": "msvc-x86-base",
"hidden": true,
"inherits": "base",
"architecture": {
"value": "Win32",
"strategy": "external"
}
},
{
"name": "clang-x64-base",
"hidden": true,
"inherits": "base",
"cacheVariables": {
"CMAKE_C_COMPILER": "clang",
"CMAKE_CXX_COMPILER": "clang++",
"NONET": {
"type": "BOOL",
"value": "ON"
}
}
},
{
"name": "gcc-base",
"hidden": true,
"inherits": "base",
"cacheVariables": {
"CMAKE_C_COMPILER": "gcc",
"CMAKE_CXX_COMPILER": "g++"
}
},
{
"name": "msvc-x64-Debug",
"inherits": "msvc-x64-base",
"displayName": "MSVC x64 Debug (SDL2)",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "msvc-x64-Debug-Translations",
"inherits": "msvc-x64-base",
"displayName": "MSVC x64 Debug (SDL2) + Translations",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"USE_GETTEXT_FROM_VCPKG": {
"type": "BOOL",
"value": "ON"
}
}
},
{
"name": "msvc-x64-Debug-SDL1",
"inherits": "msvc-x64-base",
"displayName": "MSVC x64 Debug (SDL1)",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"USE_SDL1": {
"type": "BOOL",
"value": "ON"
}
}
},
{
"name": "msvc-x64-Release",
"inherits": "msvc-x64-base",
"displayName": "MSVC x64 Release (SDL2)",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"CPACK": {
"type": "BOOL",
"value": "OFF"
}
}
},
{
"name": "msvc-x64-RelWithDebInfo",
"inherits": "msvc-x64-base",
"displayName": "MSVC x64 RelWithDebInfo (SDL2)",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
"CPACK": {
"type": "BOOL",
"value": "OFF"
}
}
},
{
"name": "msvc-x86-Debug",
"inherits": "msvc-x86-base",
"displayName": "MSVC x86 Debug (SDL2)",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "msvc-x86-Release",
"inherits": "msvc-x86-base",
"displayName": "MSVC x86 Release (SDL2)",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"CPACK": {
"type": "BOOL",
"value": "OFF"
}
}
},
{
"name": "clang-x64-Debug",
"inherits": "clang-x64-base",
"displayName": "Clang x64 Debug (SDL2)",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "clang-x64-Release",
"inherits": "clang-x64-base",
"displayName": "Clang x64 Release (SDL2)",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "clang-x64-RelWithDebInfo",
"inherits": "clang-x64-base",
"displayName": "Clang x64 RelWithDebInfo (SDL2)",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
}
},
{
"name": "gcc-x64-Debug",
"inherits": "gcc-base",
"displayName": "Linux x64 Debug (GCC)",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
}
],
"buildPresets": [
{
"name": "msvc-x64-Debug",
"configurePreset": "msvc-x64-Debug"
},
{
"name": "msvc-x64-Debug-Translations",
"configurePreset": "msvc-x64-Debug-Translations"
},
{
"name": "msvc-x64-Debug-SDL1",
"configurePreset": "msvc-x64-Debug-SDL1"
},
{
"name": "msvc-x64-Release",
"configurePreset": "msvc-x64-Release"
},
{
"name": "msvc-x64-RelWithDebInfo",
"configurePreset": "msvc-x64-RelWithDebInfo"
},
{
"name": "msvc-x86-Debug",
"configurePreset": "msvc-x86-Debug"
},
{
"name": "msvc-x86-Release",
"configurePreset": "msvc-x86-Release"
},
{
"name": "clang-x64-Debug",
"configurePreset": "clang-x64-Debug"
},
{
"name": "clang-x64-Release",
"configurePreset": "clang-x64-Release"
},
{
"name": "clang-x64-RelWithDebInfo",
"configurePreset": "clang-x64-RelWithDebInfo"
},
{
"name": "gcc-x64-Debug",
"configurePreset": "gcc-x64-Debug"
}
],
"testPresets": [
{
"name": "msvc-x64-Debug",
"configurePreset": "msvc-x64-Debug",
"output": {
"outputOnFailure": true
}
},
{
"name": "msvc-x64-RelWithDebInfo",
"configurePreset": "msvc-x64-RelWithDebInfo",
"output": {
"outputOnFailure": true
}
},
{
"name": "clang-x64-Debug",
"configurePreset": "clang-x64-Debug",
"output": {
"outputOnFailure": true
}
},
{
"name": "clang-x64-RelWithDebInfo",
"configurePreset": "clang-x64-RelWithDebInfo",
"output": {
"outputOnFailure": true
}
},
{
"name": "gcc-x64-Debug",
"configurePreset": "gcc-x64-Debug",
"output": {
"outputOnFailure": true
}
}
]
}
-152
View File
@@ -1,152 +0,0 @@
{
"configurations": [
{
"name": "x64-Debug",
"generator": "Ninja",
"configurationType": "Debug",
"buildRoot": "${workspaceRoot}\\build\\${name}",
"installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}",
"inheritEnvironments": [ "msvc_x64" ],
"intelliSenseMode": "windows-msvc-x64",
"enableClangTidyCodeAnalysis": true,
"variables": [
{
"name": "DISCORD_INTEGRATION",
"value": "True",
"type": "BOOL"
}
]
},
{
"name": "x64-Debug-Translations",
"generator": "Ninja",
"configurationType": "Debug",
"buildRoot": "${workspaceRoot}\\build\\${name}",
"installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}",
"inheritEnvironments": [ "msvc_x64" ],
"intelliSenseMode": "windows-msvc-x64",
"enableClangTidyCodeAnalysis": true,
"variables": [
{
"name": "DISCORD_INTEGRATION",
"value": "True",
"type": "BOOL"
},
{
"name": "USE_GETTEXT_FROM_VCPKG",
"value": "True",
"type": "BOOL"
}
]
},
{
"name": "x64-Debug-SDL1",
"generator": "Ninja",
"configurationType": "Debug",
"buildRoot": "${workspaceRoot}\\build\\${name}",
"installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}",
"inheritEnvironments": [ "msvc_x64" ],
"intelliSenseMode": "windows-msvc-x64",
"cmakeCommandArgs": "-DUSE_SDL1=ON",
"enableClangTidyCodeAnalysis": true,
"variables": [
{
"name": "DISCORD_INTEGRATION",
"value": "True",
"type": "BOOL"
}
]
},
{
"name": "x64-Release",
"generator": "Ninja",
"configurationType": "Release",
"buildRoot": "${workspaceRoot}\\build\\${name}",
"installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}",
"cmakeCommandArgs": "-DCPACK=ON",
"inheritEnvironments": [ "msvc_x64" ],
"intelliSenseMode": "windows-msvc-x64",
"enableClangTidyCodeAnalysis": true,
"variables": [
{
"name": "DISCORD_INTEGRATION",
"value": "True",
"type": "BOOL"
}
]
},
{
"name": "x64-RelWithDebInfo",
"generator": "Ninja",
"configurationType": "RelWithDebInfo",
"buildRoot": "${workspaceRoot}\\build\\${name}",
"installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}",
"cmakeCommandArgs": "-DCPACK=ON",
"inheritEnvironments": [ "msvc_x64" ],
"intelliSenseMode": "windows-msvc-x64",
"enableClangTidyCodeAnalysis": true,
"variables": [
{
"name": "DISCORD_INTEGRATION",
"value": "True",
"type": "BOOL"
}
]
},
{
"name": "x86-Debug",
"generator": "Ninja",
"configurationType": "Debug",
"buildRoot": "${workspaceRoot}\\build\\${name}",
"installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}",
"inheritEnvironments": [ "msvc_x86" ],
"intelliSenseMode": "windows-msvc-x86",
"enableClangTidyCodeAnalysis": true,
"variables": [
{
"name": "DISCORD_INTEGRATION",
"value": "True",
"type": "BOOL"
}
]
},
{
"name": "x86-Release",
"generator": "Ninja",
"configurationType": "Release",
"buildRoot": "${workspaceRoot}\\build\\${name}",
"installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}",
"cmakeCommandArgs": "-DCPACK=ON",
"inheritEnvironments": [ "msvc_x86" ],
"intelliSenseMode": "windows-msvc-x86",
"enableClangTidyCodeAnalysis": true,
"variables": [
{
"name": "DISCORD_INTEGRATION",
"value": "True",
"type": "BOOL"
}
]
},
{
"name": "x64-Debug-WSL-GCC",
"generator": "Ninja",
"configurationType": "Debug",
"buildRoot": "${workspaceRoot}\\build\\${name}",
"installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}",
"cmakeExecutable": "cmake",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": "",
"inheritEnvironments": [ "linux_x64" ],
"wslPath": "${defaultWSLPath}",
"variables": [
{
"name": "DISCORD_INTEGRATION",
"value": "True",
"type": "BOOL"
}
]
}
]
}
-91
View File
@@ -1,91 +0,0 @@
{
"version": 3,
"cmakeMinimumRequired": {
"major": 3,
"minor": 19,
"patch": 0
},
"configurePresets": [
{
"name": "ninja-vcpkg",
"displayName": "Ninja with VcPkg Configure Settings",
"description": "Configure with vcpkg toolchain",
"binaryDir": "${sourceDir}/build-${presetName}",
"generator": "Ninja",
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": {
"type": "FILEPATH",
"value": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
}
}
},
{
"name": "ninja-vcpkg-debug",
"displayName": "Ninja with VcPkg Configure Settings with CMAKE_BUILD_TYPE=Debug",
"inherits": "ninja-vcpkg",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "ninja-vcpkg-relwithdebinfo",
"displayName": "Ninja with VcPkg Configure Settings with CMAKE_BUILD_TYPE=RelWithDebInfo",
"inherits": "ninja-vcpkg",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
"DISABLE_LTO": {
"type": "BOOL",
"value": "ON"
}
}
},
{
"name": "ninja-vcpkg-discord-relwithdebinfo",
"displayName": "Ninja with VcPkg Configure Settings with DISCORD_INTEGRATION=ON CMAKE_BUILD_TYPE=RelWithDebInfo",
"inherits": "ninja-vcpkg-relwithdebinfo",
"cacheVariables": {
"DISCORD_INTEGRATION": {
"type": "BOOL",
"value": "ON"
}
}
}
],
"buildPresets": [
{
"name": "ninja-vcpkg-debug",
"configurePreset": "ninja-vcpkg-debug",
"displayName": "Build ninja-vcpkg-debug",
"description": "Build ninja-vcpkg-debug Configuration"
},
{
"name": "ninja-vcpkg-relwithdebinfo",
"configurePreset": "ninja-vcpkg-relwithdebinfo",
"displayName": "Build ninja-vcpkg-relwithdebinfo",
"description": "Build ninja-vcpkg-relwithdebinfo Configuration"
},
{
"name": "ninja-vcpkg-discord-relwithdebinfo",
"configurePreset": "ninja-vcpkg-discord-relwithdebinfo",
"displayName": "Build ninja-vcpkg-discord-relwithdebinfo",
"description": "Build ninja-vcpkg-discord-relwithdebinfo Configuration"
}
],
"testPresets": [
{
"name": "ninja-vcpkg-debug",
"configurePreset": "ninja-vcpkg-debug",
"output": {"outputOnFailure": true}
},
{
"name": "ninja-vcpkg-relwithdebinfo",
"configurePreset": "ninja-vcpkg-relwithdebinfo",
"output": {"outputOnFailure": true}
},
{
"name": "ninja-vcpkg-discord-relwithdebinfo",
"configurePreset": "ninja-vcpkg-discord-relwithdebinfo",
"output": {"outputOnFailure": true}
}
]
}
+13 -8
View File
@@ -268,18 +268,23 @@ cmake --build build -j $(getconf _NPROCESSORS_ONLN) --target package
Make sure to install the workload `Desktop development with C++` and the individual components `C++ CMake tools for Windows` and `Windows SDK` for Visual Studio.
*Note: `Windows SDK` component should match your Windows build version.*
Install [Git for Windows](https://gitforwindows.org/)
Install [Git for Windows](https://gitforwindows.org/).
Run the following commands in Command Prompt or Powershell
Run the following commands in Powershell
~~~ bat
~~~ powershell
git clone https://github.com/microsoft/vcpkg
cd vcpkg
bootstrap-vcpkg.bat
vcpkg integrate install
.\bootstrap-vcpkg.bat
[Environment]::SetEnvironmentVariable("VCPKG_ROOT", $PWD.Path, "User")
$env:VCPKG_ROOT = $PWD.Path
~~~
If you need additional instructions for vcpkg you can find the documentation [here](https://github.com/microsoft/vcpkg#quick-start-windows).
If you need additional instructions for vcpkg you can find the documentation [here](https://learn.microsoft.com/vcpkg/get_started/get-started).
### If you want to build via clang (optional)
In the Visual Studio installer, install the individual component `C++ Clang Compiler for Windows`.
### If you want to build the devilutionX.mpq File (optional)
@@ -291,13 +296,13 @@ The location of this tool will need to be [added to the system's PATH environmen
* **Through Open->CMake in Visual Studio**
1. Go to `File -> Open -> CMake`, select `CMakeLists.txt` from the project root.
2. Select the `x64-Release` configuration (or `x86` for 32 bit builds, `-Debug` for debug builds).
2. Select the `msvc-x64-Release` configuration (or `x86` for 32 bit builds, `-Debug` for debug builds).
3. Select `Build devilution.exe` from the `Build` menu.
* **Through GCC/WSL in Visual Studio**
1. Ensure the WSL environment has the build pre-requisites for both devilutionX (see "Installing Dependencies on Debian and Ubuntu" under the "Linux" section above) and [WSL remote development](https://docs.microsoft.com/en-us/cpp/linux/connect-to-your-remote-linux-computer?view=msvc-160#connect-to-wsl).
2. Select the `WSL-GCC-x64-Debug` configuration.
2. Select the `gcc-x64-Debug` configuration.
3. Select `Build devilution` from the `Build` menu.
* **Through cmake-gui**