Skip to content

Commit d7aeb05

Browse files
committed
Add CMake-Presets Based configuration
- Change the Powershell BuildEngine.ps1 script to use the Cmake Preset Commands - Move the CMake Configuration to the CMakePreset.json file - Harmonize the Build Configurations and multiple Architecture support by adding an Architecture Parameter the the BuildEngine.ps1 and RunTests.ps1 scripts - Update CI workflows and CMakeFiles to better support the Configurations and Architectures. - Vulkan-Loader no longer compiled in the BuildEngine.ps1 script and is now part of the CMake add_subdirectory workflow which brings consistency. - Removal of unnecessary CMake `target_include_directory` calls in `externals.cmake` and `imgui/CMakeLists.txt` as each target communicates its includes through the `target_link_libraries()` command.
1 parent 2bc58e9 commit d7aeb05

File tree

14 files changed

+260
-180
lines changed

14 files changed

+260
-180
lines changed

.github/workflows/job-cmakebuild-macOS.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,24 @@ on:
1818
jobs:
1919
cmake-build:
2020
name: cmake-build-macOS-${{ inputs.architecture }}-${{ inputs.configuration }}
21-
runs-on: ${{ inputs.architecture == 'x64' && 'macos-13' || 'macos-14' }}
21+
runs-on: ${{ 'macos-13' || 'macos-14' }}
2222
steps:
2323
- name: Checkout repository
2424
uses: actions/checkout@v4
2525

2626
- name: CMake Build
27-
run: .\Scripts\BuildEngine.ps1 -Configurations ${{inputs.configuration}} -RunClangFormat 0
27+
run: .\Scripts\BuildEngine.ps1 -Configurations ${{inputs.configuration}} -Architecture ${{inputs.architecture}} -RunClangFormat 0
2828
shell: pwsh
2929

3030
- name: Publish Build Artifacts
3131
uses: actions/upload-artifact@v4
3232
with:
3333
name: Build-macOS-${{ inputs.architecture }}-${{inputs.configuration}}
3434
path: |
35-
Result.Darwin.x64.${{inputs.configuration}}/Panzerfaust/${{inputs.configuration}}/${{inputs.targetFramework}}/osx-${{ inputs.architecture }}/publish/
36-
Result.Darwin.x64.${{inputs.configuration}}/__externals/Vulkan-Loader/loader/${{ inputs.configuration }}/
37-
Result.Darwin.x64.${{inputs.configuration}}/ZEngine/tests/${{inputs.configuration}}/
38-
!Result.Darwin.x64.${{inputs.configuration}}/Panzerfaust/${{inputs.configuration}}/${{inputs.targetFramework}}/**/Microsoft.CodeAnalysis.CSharp.resources.dll
39-
!Result.Darwin.x64.${{inputs.configuration}}/Panzerfaust/${{inputs.configuration}}/${{inputs.targetFramework}}/**/Microsoft.CodeAnalysis.CSharp.Scripting.resources.dll
40-
!Result.Darwin.x64.${{inputs.configuration}}/Panzerfaust/${{inputs.configuration}}/${{inputs.targetFramework}}/**/Microsoft.CodeAnalysis.resources.dll
41-
!Result.Darwin.x64.${{inputs.configuration}}/Panzerfaust/${{inputs.configuration}}/${{inputs.targetFramework}}/**/Microsoft.CodeAnalysis.Scripting.resources.dll
35+
Result.Darwin.${{inputs.architecture}}.${{inputs.configuration}}/Panzerfaust/${{inputs.configuration}}/${{inputs.targetFramework}}/osx-${{ inputs.architecture }}/publish/
36+
Result.Darwin.${{inputs.architecture}}.${{inputs.configuration}}/__externals/Vulkan-Loader/loader/${{ inputs.configuration }}/
37+
Result.Darwin.${{inputs.architecture}}.${{inputs.configuration}}/ZEngine/tests/${{inputs.configuration}}/
38+
!Result.Darwin.${{inputs.architecture}}.${{inputs.configuration}}/Panzerfaust/${{inputs.configuration}}/${{inputs.targetFramework}}/**/Microsoft.CodeAnalysis.CSharp.resources.dll
39+
!Result.Darwin.${{inputs.architecture}}.${{inputs.configuration}}/Panzerfaust/${{inputs.configuration}}/${{inputs.targetFramework}}/**/Microsoft.CodeAnalysis.CSharp.Scripting.resources.dll
40+
!Result.Darwin.${{inputs.architecture}}.${{inputs.configuration}}/Panzerfaust/${{inputs.configuration}}/${{inputs.targetFramework}}/**/Microsoft.CodeAnalysis.resources.dll
41+
!Result.Darwin.${{inputs.architecture}}.${{inputs.configuration}}/Panzerfaust/${{inputs.configuration}}/${{inputs.targetFramework}}/**/Microsoft.CodeAnalysis.Scripting.resources.dll

.github/workflows/job-cmakebuild-windows.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,10 @@ jobs:
3838
!Result.Windows.x64.MultiConfig/Panzerfaust/${{inputs.configuration}}/${{inputs.targetFramework}}/**/createdump.exe
3939
4040
- name: Publish Vulkan Build Artifacts
41-
if: ${{ inputs.configuration == 'Release'}}
4241
uses: actions/upload-artifact@v4
4342
with:
44-
name: Vulkan-build-x64-release
43+
name: Vulkan-build-x64-${{inputs.configuration}}
4544
path: |
46-
Result.Windows.x64.MultiConfig/__externals/Vulkan-Loader/loader/release/vulkan-1.dll
47-
Result.Windows.x64.MultiConfig/__externals/Vulkan-Loader/loader/release/vulkan-1.exp
48-
Result.Windows.x64.MultiConfig/__externals/Vulkan-Loader/loader/release/vulkan-1.lib
45+
Result.Windows.x64.MultiConfig/__externals/Vulkan-Loader/loader/${{inputs.configuration}}/vulkan-1.dll
46+
Result.Windows.x64.MultiConfig/__externals/Vulkan-Loader/loader/${{inputs.configuration}}/vulkan-1.exp
47+
Result.Windows.x64.MultiConfig/__externals/Vulkan-Loader/loader/${{inputs.configuration}}/vulkan-1.lib

.github/workflows/job-deploy-macOS.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ on:
1818
jobs:
1919
deploy:
2020
name: deploy-macOS-${{ inputs.architecture }}-${{ inputs.configuration }}
21-
runs-on: ${{ inputs.architecture == 'x64' && 'macos-13' || 'macos-latest' }}
21+
runs-on: ${{ 'macos-13' || 'macos-latest' }}
2222
steps:
2323
- uses: actions/download-artifact@v4
2424
with:
@@ -29,4 +29,4 @@ jobs:
2929
uses: actions/upload-artifact@v4
3030
with:
3131
name: macOS-${{ inputs.architecture }}-${{ inputs.configuration }}
32-
path: Result.Darwin.x64.${{ inputs.configuration }}/Panzerfaust/${{ inputs.configuration }}/${{inputs.targetFramework}}/osx-${{ inputs.architecture }}/publish/
32+
path: Result.Darwin.${{inputs.architecture}}.${{ inputs.configuration }}/Panzerfaust/${{ inputs.configuration }}/${{inputs.targetFramework}}/osx-${{ inputs.architecture }}/publish/

.github/workflows/job-test-macOS.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ on:
1515
jobs:
1616
test:
1717
name: test-macOS-${{ inputs.architecture }}-${{ inputs.configuration }}
18-
runs-on: ${{ inputs.architecture == 'x64' && 'macos-13' || 'macos-latest' }}
18+
runs-on: ${{ 'macos-13' || 'macos-latest' }}
1919
steps:
2020
- name: Checkout repository
2121
uses: actions/checkout@v4
@@ -24,11 +24,11 @@ jobs:
2424
uses: actions/download-artifact@v4
2525
with:
2626
name: Build-macOS-${{ inputs.architecture }}-${{ inputs.configuration }}
27-
path: Result.Darwin.x64.${{ inputs.configuration }}
27+
path: Result.Darwin.${{inputs.architecture}}.${{ inputs.configuration }}
2828

2929
- name: Update access permission of ZEngineTests
30-
run: chmod +x ./Result.Darwin.x64.${{ inputs.configuration }}/ZEngine/tests/${{ inputs.configuration }}/ZEngineTests
30+
run: chmod +x ./Result.Darwin.${{inputs.architecture}}.${{ inputs.configuration }}/ZEngine/tests/${{ inputs.configuration }}/ZEngineTests
3131

3232
- name: Run Tests
33-
run: .\Scripts\RunTests.ps1 -Configurations ${{ inputs.configuration }}
33+
run: .\Scripts\RunTests.ps1 -Configurations ${{ inputs.configuration }} -Architecture ${{ inputs.architecture }}
3434
shell: pwsh

.github/workflows/job-test-windows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
uses: actions/download-artifact@v4
2828
with:
2929
path: vulkan-build
30-
name: Vulkan-build-x64-release
30+
name: Vulkan-build-x64-${{inputs.configuration}}
3131

3232
- name: Run Tests
3333
shell: pwsh

CMakeLists.txt

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ endif()
4242
# Externals dependencies
4343
#
4444
if (NOT LAUNCHER_ONLY)
45+
add_subdirectory (${EXTERNAL_DIR}/Vulkan-Headers)
46+
add_subdirectory (${EXTERNAL_DIR}/Vulkan-Loader)
4547
add_subdirectory (${EXTERNAL_DIR}/fmt)
4648
add_subdirectory (${EXTERNAL_DIR}/imgui)
4749
add_subdirectory (${EXTERNAL_DIR}/glfw)
@@ -59,12 +61,8 @@ if (NOT LAUNCHER_ONLY)
5961
add_subdirectory (${EXTERNAL_DIR}/tlsf)
6062
add_subdirectory (${EXTERNAL_DIR}/rapidhash)
6163
add_subdirectory (${EXTERNAL_DIR}/CLI11)
64+
add_subdirectory (${EXTERNAL_DIR}/nlohmann_json)
6265

63-
set (CMAKE_PREFIX_PATH
64-
${CMAKE_PREFIX_PATH}
65-
${EXTERNAL_DIR}/Vulkan-Headers/build/install/share/cmake
66-
)
67-
add_subdirectory (${EXTERNAL_DIR}/Vulkan-Loader)
6866

6967
# Core engine lib is here
7068
#
@@ -91,20 +89,20 @@ endif ()
9189
#
9290
set (SYSTEM_NAME ${CMAKE_SYSTEM_NAME})
9391
if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
94-
set (SYSTEM_ARCHITECTURE "win-x64")
92+
set (SYSTEM_ARCHITECTURE "x64")
9593
elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
96-
set (SYSTEM_ARCHITECTURE "linux-x64")
94+
set (SYSTEM_ARCHITECTURE "x64")
9795
elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
9896
if (MACOSX_ARCHITECTURE_ARM64)
99-
set (SYSTEM_ARCHITECTURE "osx-arm64")
97+
set (SYSTEM_ARCHITECTURE "arm64")
10098
else ()
101-
set (SYSTEM_ARCHITECTURE "osx-x64")
99+
set (SYSTEM_ARCHITECTURE "x64")
102100
endif ()
103101
endif ()
104102

105103
add_custom_target (AssembleContent ALL
106104
COMMENT "Copying assets and resources contents"
107-
COMMAND pwsh ${CMAKE_CURRENT_SOURCE_DIR}/Scripts/PostBuild.ps1 -SystemName ${SYSTEM_NAME} -Architectures ${SYSTEM_ARCHITECTURE} -Configurations $<IF:$<CONFIG:Debug>,Debug,Release> $<$<BOOL:${LAUNCHER_ONLY}>:-LauncherOnly>
105+
COMMAND pwsh ${CMAKE_CURRENT_SOURCE_DIR}/Scripts/PostBuild.ps1 -SystemName ${SYSTEM_NAME} -Architecture ${SYSTEM_ARCHITECTURE} -Configurations $<IF:$<CONFIG:Debug>,Debug,Release> $<$<BOOL:${LAUNCHER_ONLY}>:-LauncherOnly>
108106
)
109107

110108
if (NOT LAUNCHER_ONLY)

CMakePresets.json

Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
{
2+
"version": 10,
3+
"cmakeMinimumRequired": {
4+
"major": 3,
5+
"minor": 23,
6+
"patch": 0
7+
},
8+
"configurePresets":[
9+
{
10+
"name": "BaseOptions",
11+
"cacheVariables": {
12+
"CMAKE_BUILD_TYPE": "Debug",
13+
14+
"VULKAN_HEADERS_ENABLE_INSTALL": "ON",
15+
"ENTT_INCLUDE_HEADERS": "ON",
16+
17+
"SPDLOG_BUILD_SHARED": "OFF",
18+
"SPDLOG_FMT_EXTERNAL": "ON",
19+
"SPDLOG_FMT_EXTERNAL_HO": "OFF",
20+
21+
"GLFW_BUILD_DOCS": "OFF",
22+
"GLFW_BUILD_EXAMPLES": "OFF",
23+
"GLFW_INSTALL": "OFF",
24+
25+
"ASSIMP_BUILD_TESTS": "OFF",
26+
"ASSIMP_INSTALL": "OFF",
27+
"ASSIMP_BUILD_SAMPLES": "OFF",
28+
"ASSIMP_BUILD_ASSIMP_TOOLS": "OFF",
29+
"ASSIMP_BUILD_ALL_IMPORTERS_BY_DEFAULT": "OFF",
30+
"ASSIMP_BUILD_OBJ_IMPORTER": "ON",
31+
"ASSIMP_BUILD_ALL_EXPORTERS_BY_DEFAULT": "OFF",
32+
"ASSIMP_BUILD_OBJ_EXPORTER": "ON",
33+
34+
"UUID_BUILD_TESTS": "OFF",
35+
"UUID_USING_CXX20_SPAN": "ON",
36+
"UUID_SYSTEM_GENERATOR": "OFF",
37+
38+
"YAML_CPP_BUILD_TOOLS": "OFF",
39+
"YAML_CPP_BUILD_TESTS": "OFF",
40+
"YAML_CPP_FORMAT_SOURCE": "OFF",
41+
"YAML_BUILD_SHARED_LIBS": "OFF",
42+
43+
"USE_MASM": "OFF",
44+
"USE_GAS": "OFF",
45+
46+
"SPIRV_SKIP_EXECUTABLES": "ON",
47+
"SPIRV_SKIP_TESTS": "ON",
48+
"GLSLANG_ENABLE_INSTALL": "ON",
49+
"ALLOW_EXTERNAL_SPIRV_TOOLS": "OFF",
50+
51+
"SPIRV_CROSS_ENABLE_TESTS": "OFF",
52+
"CMAKE_POLICY_VERSION_MINIMUM": "3.5"
53+
54+
}
55+
},
56+
{
57+
"name": "Windows_x64_Debug",
58+
"inherits": "BaseOptions",
59+
"displayName": "Windows Visual Studio Debug",
60+
"generator": "Visual Studio 17 2022",
61+
"binaryDir": "Result.Windows.x64.MultiConfig",
62+
"architecture": "x64",
63+
"cacheVariables": {
64+
"CMAKE_BUILD_TYPE": "Debug",
65+
"CMAKE_CONFIGURATION_TYPES": "Debug"
66+
}
67+
68+
},
69+
{
70+
"name": "Windows_x64_Release",
71+
"displayName": "Windows Visual Studio Release",
72+
"inherits": "Windows_x64_Debug",
73+
"cacheVariables": {
74+
"CMAKE_BUILD_TYPE": "Release",
75+
"CMAKE_CONFIGURATION_TYPES": "Release"
76+
}
77+
},
78+
79+
{
80+
"name": "Darwin_x64_Debug",
81+
"inherits": "BaseOptions",
82+
"displayName": "Darwin XCode Debug",
83+
"binaryDir": "Result.Darwin.x64.Debug",
84+
"generator": "Xcode",
85+
"cacheVariables": {
86+
"BUILD_FRAMEWORK": "ON"
87+
}
88+
},
89+
{
90+
"name": "Darwin_x64_Release",
91+
"inherits": "Darwin_x64_Debug",
92+
"displayName": "Darwin XCode Release",
93+
"binaryDir": "Result.Darwin.x64.Release",
94+
"cacheVariables": {
95+
"CMAKE_BUILD_TYPE": "Release"
96+
}
97+
},
98+
99+
{
100+
"name": "Darwin_arm64_Debug",
101+
"inherits": "Darwin_x64_Debug",
102+
"binaryDir": "Result.Darwin.arm64.Debug",
103+
"displayName": "Darwin ARM XCode Debug"
104+
},
105+
106+
{
107+
"name": "Darwin_arm64_Release",
108+
"inherits": "Darwin_x64_Release",
109+
"binaryDir": "Result.Darwin.arm64.Release",
110+
"displayName": "Darwin ARM XCode Release"
111+
},
112+
113+
{
114+
"name": "Linux_x64_Debug",
115+
"inherits": "BaseOptions",
116+
"displayName": "Linux Ninja Debug",
117+
"binaryDir": "Result.Linux.x64.Debug",
118+
"generator": "Ninja"
119+
},
120+
{
121+
"name": "Linux_x64_Release",
122+
"inherits": "Linux_x64_Debug",
123+
"displayName": "Linux Ninja Release",
124+
"binaryDir": "Result.Linux.x64.Release",
125+
"generator": "Ninja",
126+
"cacheVariables": {
127+
"CMAKE_BUILD_TYPE": "Release"
128+
}
129+
}
130+
],
131+
132+
"buildPresets": [
133+
{
134+
"name": "Windows_x64_Debug",
135+
"configurePreset": "Windows_x64_Debug",
136+
"configuration": "Debug",
137+
"nativeToolOptions": [
138+
"-nodeReuse:false"
139+
]
140+
},
141+
{
142+
"name": "Windows_x64_Release",
143+
"configurePreset": "Windows_x64_Release",
144+
"configuration": "Release",
145+
"nativeToolOptions": [
146+
"-nodeReuse:false"
147+
]
148+
},
149+
150+
{
151+
"name": "Darwin_x64_Debug",
152+
"configuration": "Debug",
153+
"configurePreset": "Darwin_x64_Debug"
154+
},
155+
{
156+
"name": "Darwin_x64_Release",
157+
"configuration": "Release",
158+
"configurePreset": "Darwin_x64_Release"
159+
},
160+
161+
{
162+
"name": "Darwin_arm64_Debug",
163+
"configuration": "Debug",
164+
"configurePreset": "Darwin_arm64_Debug"
165+
},
166+
{
167+
"name": "Darwin_arm64_Release",
168+
"configuration": "Release",
169+
"configurePreset": "Darwin_arm64_Release"
170+
},
171+
172+
{
173+
"name": "Linux_x64_Debug",
174+
"configurePreset": "Linux_x64_Debug"
175+
},
176+
{
177+
"name": "Linux_x64_Release",
178+
"configurePreset": "Linux_x64_Release"
179+
}
180+
]
181+
}

0 commit comments

Comments
 (0)