Skip to content

Commit 47dc7ab

Browse files
committed
CMake: Use separate files for Windows and Linux presets
1 parent 1d6d73b commit 47dc7ab

File tree

7 files changed

+83
-90
lines changed

7 files changed

+83
-90
lines changed

.github/workflows/main.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ jobs:
2222
os:
2323
- runs-on: windows-2022
2424
vcpkg-triplet: x86-windows-static
25-
preset: ci-windows
25+
suffix: ci-windows
2626
- runs-on: ubuntu-22.04
2727
vcpkg-triplet: x86-linux
28-
preset: ci-linux
28+
suffix: ci-linux
2929
target: [client, server]
3030

3131
# The type of runner that the job will run on
@@ -66,29 +66,29 @@ jobs:
6666
uses: lukka/run-cmake@v10
6767
id: runcmake
6868
with:
69-
configurePreset: '${{ matrix.os.preset }}'
70-
buildPreset: '${{ matrix.os.preset }}'
69+
configurePreset: github-actions
70+
buildPreset: github-actions
7171
buildPresetAdditionalArgs: "['--target', 'ci-${{ matrix.target }}']"
72-
testPreset: '${{ matrix.os.preset }}'
72+
testPreset: github-actions
7373
testPresetAdditionalArgs: "['-R', '${{ matrix.target }}']"
7474
env:
7575
VCPKG_FORCE_SYSTEM_BINARIES: 1
7676

7777
# Install
7878
- name: Install with CMake
7979
run: |
80-
cmake --install ${{github.workspace}}/_build/${{ matrix.os.preset }} --prefix ${{github.workspace}}/_build/ci-install --component ${{ matrix.target }}
80+
cmake --install ${{github.workspace}}/_build/github-actions --config RelWithDebInfo --prefix ${{github.workspace}}/_build/ci-install --component ${{ matrix.target }}
8181
8282
# Prepare artifact
8383
- name: Prepare artifact
8484
id: prepare_artifact
8585
run: >
8686
python scripts/package_target.py
87-
--build-dir ${{github.workspace}}/_build/${{ matrix.os.preset }}
87+
--build-dir ${{github.workspace}}/_build/github-actions
8888
--install-dir ${{github.workspace}}/_build/ci-install
8989
--artifact-dir ${{github.workspace}}/_build/ci-artifact
9090
--target ${{ matrix.target }}
91-
--suffix ${{ matrix.os.preset }}
91+
--suffix ${{ matrix.os.suffix }}
9292
9393
# Upload result
9494
- name: Upload build result

.vscode/settings.example.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools",
77
"clangd.arguments": [
88
"-header-insertion=never",
9-
"--compile-commands-dir=_build/user-debug"
9+
"--compile-commands-dir=_build/user"
1010
],
1111
"cmake.useCMakePresets": "always"
1212
}

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Bugfixed and Improved Half-Life Release
33
#
44

5-
cmake_minimum_required( VERSION 3.25.0 )
5+
cmake_minimum_required( VERSION 3.30.0 )
66

77
# Use static MSVC runtime
88
set( CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>" )

CMakePresets.json

Lines changed: 20 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
{
2-
"version": 4,
2+
"version": 9,
3+
"cmakeMinimumRequired": {
4+
"major": 3,
5+
"minor": 30
6+
},
7+
"include": [
8+
"cmake/CMake${hostSystemName}Presets.json"
9+
],
310
"configurePresets": [
411
{
5-
"name": "default",
12+
"name": "base",
13+
"inherits": ["vcpkg"],
614
"binaryDir": "${sourceDir}/_build/${presetName}",
715
"hidden": true,
816
"cacheVariables": {
@@ -15,83 +23,34 @@
1523
}
1624
},
1725
{
18-
"name": "vcpkg-windows",
19-
"inherits": ["default"],
20-
"toolchainFile": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
21-
"generator": "Ninja",
22-
"cacheVariables": {
23-
"CMAKE_BUILD_TYPE": "Debug",
24-
"VCPKG_HOST_TRIPLET": "x86-windows-static",
25-
"VCPKG_TARGET_TRIPLET": "x86-windows-static"
26-
}
27-
},
28-
{
29-
"name": "vcpkg-linux",
30-
"inherits": ["default"],
31-
"toolchainFile": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
32-
"generator": "Ninja",
33-
"cacheVariables": {
34-
"CMAKE_BUILD_TYPE": "Debug",
35-
"VCPKG_HOST_TRIPLET": "x86-linux",
36-
"VCPKG_TARGET_TRIPLET": "x86-linux",
37-
"VCPKG_CHAINLOAD_TOOLCHAIN_FILE": "${sourceDir}/cmake/toolchains/linux-gcc.cmake"
38-
}
39-
},
40-
{
41-
"name": "ci-base",
42-
"hidden": true,
26+
"name": "github-actions",
27+
"inherits": ["base"],
28+
"generator": "Ninja Multi-Config",
4329
"cacheVariables": {
44-
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
4530
"BUILD_TESTING": true,
4631
"GNU_FORCE_COLORED_OUTPUT": false,
4732
"USE_UPDATER": true,
4833
"GENERATE_AMXX_OFFSETS": true,
4934
"WARNINGS_ARE_ERRORS": true
5035
}
51-
},
52-
{
53-
"name": "ci-windows",
54-
"inherits": ["ci-base", "vcpkg-windows"]
55-
},
56-
{
57-
"name": "ci-linux",
58-
"inherits": ["ci-base", "vcpkg-linux"]
5936
}
6037
],
6138
"buildPresets": [
6239
{
63-
"name": "ci-base",
64-
"hidden": true,
65-
"inheritConfigureEnvironment": true
66-
},
67-
{
68-
"name": "ci-windows",
69-
"inherits": ["ci-base"],
70-
"configurePreset": "ci-windows"
71-
},
72-
{
73-
"name": "ci-linux",
74-
"inherits": ["ci-base"],
75-
"configurePreset": "ci-linux"
40+
"name": "github-actions",
41+
"configurePreset": "github-actions",
42+
"inheritConfigureEnvironment": true,
43+
"configuration": "RelWithDebInfo"
7644
}
7745
],
7846
"testPresets": [
7947
{
80-
"name": "ci-base",
81-
"hidden": true,
48+
"name": "github-actions",
49+
"configurePreset": "github-actions",
50+
"configuration": "RelWithDebInfo",
8251
"output": {
8352
"outputOnFailure": true
8453
}
85-
},
86-
{
87-
"name": "ci-windows",
88-
"inherits": ["ci-base"],
89-
"configurePreset": "ci-windows"
90-
},
91-
{
92-
"name": "ci-linux",
93-
"inherits": ["ci-base"],
94-
"configurePreset": "ci-linux"
9554
}
9655
]
9756
}

CMakeUserPresets.example.json

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,8 @@
22
"version": 4,
33
"configurePresets": [
44
{
5-
"name": "user-debug-windows",
6-
"inherits": ["vcpkg-windows"],
7-
"generator": "Visual Studio 17 2022",
8-
"architecture": "Win32",
9-
"cacheVariables": {
10-
"AUTO_DEPLOY": true,
11-
"USE_UPDATER": true,
12-
"GENERATE_AMXX_OFFSETS": false
13-
}
14-
},
15-
{
16-
"name": "user-debug-linux",
17-
"inherits": ["vcpkg-linux"],
5+
"name": "user",
6+
"inherits": ["base", "platform-generator"],
187
"cacheVariables": {
198
"AUTO_DEPLOY": true,
209
"USE_UPDATER": true,
@@ -24,14 +13,16 @@
2413
],
2514
"buildPresets": [
2615
{
27-
"name": "user-debug-windows",
28-
"configurePreset": "user-debug-windows",
29-
"inheritConfigureEnvironment": true
16+
"name": "user-debug",
17+
"configurePreset": "user",
18+
"inheritConfigureEnvironment": true,
19+
"configuration": "Debug"
3020
},
3121
{
32-
"name": "user-debug-linux",
33-
"configurePreset": "user-debug-linux",
34-
"inheritConfigureEnvironment": true
22+
"name": "user-release",
23+
"configurePreset": "user",
24+
"inheritConfigureEnvironment": true,
25+
"configuration": "RelWithDebInfo"
3526
}
3627
]
3728
}

cmake/CMakeLinuxPresets.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"version": 4,
3+
"configurePresets": [
4+
{
5+
"name": "vcpkg",
6+
"hidden": true,
7+
"toolchainFile": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
8+
"generator": "Ninja Multi-Config",
9+
"cacheVariables": {
10+
"CMAKE_BUILD_TYPE": "Debug",
11+
"VCPKG_HOST_TRIPLET": "x86-linux",
12+
"VCPKG_TARGET_TRIPLET": "x86-linux",
13+
"VCPKG_CHAINLOAD_TOOLCHAIN_FILE": "${sourceDir}/cmake/toolchains/linux-gcc.cmake"
14+
}
15+
},
16+
{
17+
"name": "platform-generator",
18+
"hidden": true,
19+
"generator": "Ninja Multi-Config"
20+
}
21+
]
22+
}

cmake/CMakeWindowsPresets.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"version": 4,
3+
"configurePresets": [
4+
{
5+
"name": "vcpkg",
6+
"hidden": true,
7+
"toolchainFile": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
8+
"cacheVariables": {
9+
"CMAKE_BUILD_TYPE": "Debug",
10+
"VCPKG_HOST_TRIPLET": "x86-windows-static",
11+
"VCPKG_TARGET_TRIPLET": "x86-windows-static"
12+
}
13+
},
14+
{
15+
"name": "platform-generator",
16+
"hidden": true,
17+
"generator": "Visual Studio 17 2022",
18+
"architecture": "Win32"
19+
}
20+
]
21+
}

0 commit comments

Comments
 (0)