Skip to content

Commit 9dbebf6

Browse files
committed
Add CMakePreset.json config
1 parent 39ebde2 commit 9dbebf6

File tree

9 files changed

+202
-115
lines changed

9 files changed

+202
-115
lines changed

.github/workflows/Engine-CI.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
on:
22
push:
3-
branches: [ master, develop, arena-integration ]
3+
branches: [ master, develop, arena-integration, cmake_preset_linux ]
44
pull_request:
55
branches: [ master, develop, arena-integration ]
66

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,19 @@ jobs:
3131
chmod +x llvm.sh
3232
sudo ./llvm.sh 20
3333
34+
<<<<<<< HEAD
3435
- name: Update the list of packages
3536
run: sudo apt-get update
3637

3738
- name: Install Dependencies
3839
run: sudo apt-get install libasound2-dev libgl1-mesa-dev libpulse-dev libdbus-1-dev libx11-dev libxcursor-dev libxext-dev libxi-dev libxinerama-dev libxrandr-dev libxss-dev libxt-dev libxxf86vm-dev cmake apt-transport-https software-properties-common gcc g++ powershell clang-format-20 glslang-tools libwayland-dev libxkbcommon-dev
40+
=======
41+
- name: Update the list of packages after we added packages.microsoft.com
42+
run: sudo apt-get update
43+
44+
- name: Install development library
45+
run: sudo apt-get install libasound2-dev libgl1-mesa-dev libpulse-dev libdbus-1-dev libx11-dev libxcursor-dev libxext-dev libxi-dev libxinerama-dev libxrandr-dev libxss-dev libxt-dev libxxf86vm-dev cmake apt-transport-https software-properties-common gcc g++ powershell clang-format-20 libwayland-dev libxkbcommon-dev libassimp-dev libfmt-dev libstb-dev libglfw3-dev libspdlog-dev libglm-dev libyaml-cpp-dev libspirv-cross-c-shared-dev spirv-headers spirv-tools nlohmann-json3-dev libcli11-dev
46+
>>>>>>> 6449fb33 (Add CMakePreset.json config)
3947

4048
- name: CMake Build
4149
run: .\Scripts\BuildEngine.ps1 -Configurations ${{inputs.configuration}}
@@ -46,9 +54,15 @@ jobs:
4654
with:
4755
name: Build-linux-${{inputs.configuration}}
4856
path: |
57+
<<<<<<< HEAD
4958
Result.Linux.x64.${{inputs.configuration}}/Panzerfaust/${{inputs.configuration}}/${{inputs.targetFramework}}/publish/
5059
Result.Linux.x64.${{inputs.configuration}}/__externals/Vulkan-Loader/loader/
5160
Result.Linux.x64.${{inputs.configuration}}/ZEngine/tests/ZEngineTests
61+
=======
62+
Result.Linux.x64.${inputs.configuration}}/Panzerfaust/${{inputs.configuration}}/net8.0/publish
63+
Result.Linux.x64.${{inputs.configuration}}/_deps/vulkan-loader-build/loader/
64+
Result.Linux.x64.${{inputs.configuration}}/ZEngine/tests/
65+
>>>>>>> 6449fb33 (Add CMakePreset.json config)
5266
Result.Linux.x64.${{inputs.configuration}}/Panzerfaust/${{inputs.configuration}}/${{inputs.targetFramework}}/**/Microsoft.CodeAnalysis.CSharp.resources.dll
5367
!Result.Linux.x64.${{inputs.configuration}}/Panzerfaust/${{inputs.configuration}}/${{inputs.targetFramework}}/**/Microsoft.CodeAnalysis.CSharp.Scripting.resources.dll
5468
!Result.Linux.x64.${{inputs.configuration}}/Panzerfaust/${{inputs.configuration}}/${{inputs.targetFramework}}/**/Microsoft.CodeAnalysis.resources.dll

CMakeLists.txt

Lines changed: 2 additions & 5 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)
@@ -61,11 +63,6 @@ if (NOT LAUNCHER_ONLY)
6163
add_subdirectory (${EXTERNAL_DIR}/rapidhash)
6264
add_subdirectory (${EXTERNAL_DIR}/CLI11)
6365

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

7067
# Core engine lib is here
7168
#

CMakePresets.json

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
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+
"BUILD_SHARED_LIBS": "OFF",
14+
15+
"VULKAN_HEADERS_ENABLE_INSTALL": "ON",
16+
"ENTT_INCLUDE_HEADERS": "ON",
17+
18+
"SPDLOG_BUILD_SHARED": "OFF",
19+
"SPDLOG_FMT_EXTERNAL": "ON",
20+
"SPDLOG_FMT_EXTERNAL_HO": "OFF",
21+
22+
"GLFW_BUILD_DOCS": "OFF",
23+
"GLFW_BUILD_EXAMPLES": "OFF",
24+
"GLFW_INSTALL": "OFF",
25+
26+
"ASSIMP_BUILD_TESTS": "OFF",
27+
"ASSIMP_INSTALL": "OFF",
28+
"ASSIMP_BUILD_SAMPLES": "OFF",
29+
"ASSIMP_BUILD_ASSIMP_TOOLS": "OFF",
30+
"ASSIMP_BUILD_ALL_IMPORTERS_BY_DEFAULT": "OFF",
31+
"ASSIMP_BUILD_OBJ_IMPORTER": "ON",
32+
"ASSIMP_BUILD_ALL_EXPORTERS_BY_DEFAULT": "OFF",
33+
"ASSIMP_BUILD_OBJ_EXPORTER": "ON",
34+
35+
"UUID_BUILD_TESTS": "OFF",
36+
"UUID_USING_CXX20_SPAN": "ON",
37+
"UUID_SYSTEM_GENERATOR": "OFF",
38+
39+
"YAML_CPP_BUILD_TOOLS": "OFF",
40+
"YAML_CPP_BUILD_TESTS": "OFF",
41+
"YAML_CPP_FORMAT_SOURCE": "OFF",
42+
"YAML_BUILD_SHARED_LIBS": "OFF",
43+
44+
"USE_MASM": "OFF",
45+
"USE_GAS": "OFF",
46+
47+
"SPIRV_SKIP_EXECUTABLES": "ON",
48+
"SPIRV_SKIP_TESTS": "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+
},
64+
{
65+
"name": "Windows_x64_Release",
66+
"displayName": "Windows Visual Studio Release",
67+
"inherits": "Windows_x64_Debug",
68+
"cacheVariables": {
69+
"CMAKE_BUILD_TYPE": "Release"
70+
}
71+
},
72+
73+
{
74+
"name": "Darwin_x64_Debug",
75+
"inherits": "BaseOptions",
76+
"displayName": "Darwin XCode Debug",
77+
"binaryDir": "Result.Darwin.x64.Debug",
78+
"generator": "Xcode",
79+
"cacheVariables": {
80+
"BUILD_FRAMEWORK": "ON"
81+
}
82+
},
83+
{
84+
"name": "Darwin_x64_Release",
85+
"inherits": "Darwin_x64_Debug",
86+
"displayName": "Darwin XCode Release",
87+
"binaryDir": "Result.Darwin.x64.Release"
88+
},
89+
90+
{
91+
"name": "Darwin_arm_Debug",
92+
"inherits": "Darwin_x64_Debug",
93+
"binaryDir": "Result.Darwin.arm.Debug",
94+
"displayName": "Darwin ARM XCode Debug"
95+
},
96+
97+
{
98+
"name": "Darwin_arm_Release",
99+
"inherits": "Darwin_x64_Release",
100+
"binaryDir": "Result.Darwin.arm.Release",
101+
"displayName": "Darwin ARM XCode Release"
102+
},
103+
104+
{
105+
"name": "Linux_x64_Debug",
106+
"inherits": "BaseOptions",
107+
"displayName": "Linux Ninja Debug",
108+
"binaryDir": "Result.Linux.x64.Debug",
109+
"generator": "Ninja"
110+
},
111+
{
112+
"name": "Linux_x64_Release",
113+
"inherits": "Linux_x64_Debug",
114+
"displayName": "Linux Ninja Release",
115+
"binaryDir": "Result.Linux.x64.Release",
116+
"generator": "Ninja",
117+
"cacheVariables": {
118+
"CMAKE_BUILD_TYPE": "Release"
119+
}
120+
}
121+
],
122+
123+
"buildPresets": [
124+
{
125+
"name": "Windows_x64_Debug",
126+
"configurePreset": "Windows_x64_Debug",
127+
"nativeToolOptions": [
128+
"-nodeReuse:false"
129+
]
130+
},
131+
{
132+
"name": "Windows_x64_Release",
133+
"configurePreset": "Windows_x64_Release",
134+
"nativeToolOptions": [
135+
"-nodeReuse:false"
136+
]
137+
},
138+
139+
{
140+
"name": "Darwin_x64_Debug",
141+
"configurePreset": "Darwin_x64_Debug"
142+
},
143+
{
144+
"name": "Darwin_x64_Release",
145+
"configurePreset": "Darwin_x64_Release"
146+
},
147+
148+
{
149+
"name": "Darwin_arm_Debug",
150+
"configurePreset": "Darwin_arm_Debug"
151+
},
152+
{
153+
"name": "Darwin_arm_Release",
154+
"configurePreset": "Darwin_arm_Release"
155+
},
156+
157+
{
158+
"name": "Linux_x64_Debug",
159+
"configurePreset": "Linux_x64_Debug"
160+
},
161+
{
162+
"name": "Linux_x64_Release",
163+
"configurePreset": "Linux_x64_Release"
164+
}
165+
]
166+
}

Panzerfaust/CMakeLists.txt

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,17 @@ project (Panzerfaust
88
set(CSPROJ Panzerfaust)
99
set (CSPROJ_SOURCE_FILE ${CMAKE_CURRENT_LIST_DIR}/${CSPROJ}.csproj)
1010

11-
if ((APPLE) OR (${CMAKE_SYSTEM_NAME} STREQUAL "Windows"))
11+
restore_nuget_packages(${CSPROJ_SOURCE_FILE})
1212

13-
restore_nuget_packages(${CSPROJ_SOURCE_FILE})
14-
15-
if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
16-
include_external_msproject(
17-
${CSPROJ}
18-
${CSPROJ_SOURCE_FILE}
19-
PLATFORM "x64"
20-
TYPE "4301B74A-9ED7-48ED-9DE5-FC2E1457778D"
21-
GUID "FAE04EC0-301F-11D3-BF4B-00C04F79EFBC"
22-
)
23-
endif ()
24-
endif()
13+
if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
14+
include_external_msproject(
15+
${CSPROJ}
16+
${CSPROJ_SOURCE_FILE}
17+
PLATFORM "x64"
18+
TYPE "4301B74A-9ED7-48ED-9DE5-FC2E1457778D"
19+
GUID "FAE04EC0-301F-11D3-BF4B-00C04F79EFBC"
20+
)
21+
endif ()
2522

2623
set (BUILD_CONFIGURATION -c $<IF:$<CONFIG:Debug>,Debug,Release>)
2724
if (APPLE)

Scripts/BuildEngine.ps1

Lines changed: 3 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,6 @@ if(-Not $LauncherOnly) {
8888
Write-Host "Ensuring submodules are initialized and updated..."
8989
& git -C $RepoRoot submodule update --init --recursive
9090

91-
Write-Host "Configuring Vulkan-Header submodule..."
92-
93-
$ExternalVulkanHeadersDir = Join-Path -Path $RepoRoot -ChildPath "__externals/Vulkan-Headers"
94-
$ExternalVulkanHeadersOutputDir = Join-Path -Path $ExternalVulkanHeadersDir -ChildPath "build"
95-
$ExternalVulkanHeadersInstallDir = Join-Path -Path $ExternalVulkanHeadersOutputDir -ChildPath "install"
96-
97-
if(-Not (Test-Path -Path $ExternalVulkanHeadersInstallDir)) {
98-
& $cMakeProgram -S $ExternalVulkanHeadersDir -B $ExternalVulkanHeadersOutputDir
99-
& $cMakeProgram --install $ExternalVulkanHeadersOutputDir --prefix $ExternalVulkanHeadersInstallDir
100-
}
10191
} else {
10292
Write-Host "Skipping submodules initialization..."
10393
}
@@ -126,76 +116,10 @@ function Build([string]$configuration, [int]$VsVersion , [bool]$runBuild) {
126116

127117
Write-Host "Building $systemName $architecture $configuration"
128118

129-
[string]$BuildDirectoryNameExtension = If ($isMultipleConfig) { "MultiConfig" } Else { $configuration }
130-
[string]$BuildDirectoryName = "Result." + $systemName + "." + $architecture + "." + $BuildDirectoryNameExtension
131-
[string]$buildDirectoryPath = [IO.Path]::Combine($RepoRoot, $BuildDirectoryName)
132-
[string]$cMakeCacheVariableOverride = ""
133-
134-
# Create build directory
135-
if (-Not (Test-Path $buildDirectoryPath)) {
136-
$Null = New-Item -ItemType Directory -Path $BuildDirectoryPath -ErrorAction SilentlyContinue
137-
}
138-
139119
# Define CMake Generator arguments
140-
$cMakeOptions = " -DCMAKE_SYSTEM_NAME=$systemName", " -DCMAKE_BUILD_TYPE=$configuration"
141-
$submoduleCMakeOptions = @{
142-
'ENTT' = @("-DENTT_INCLUDE_HEADERS=ON")
143-
'SPDLOG' = @("-DSPDLOG_BUILD_SHARED=OFF", "-DBUILD_STATIC_LIBS=ON", "-DSPDLOG_FMT_EXTERNAL=ON", "-DSPDLOG_FMT_EXTERNAL_HO=OFF");
144-
'GLFW ' = @("-DGLFW_BUILD_DOCS=OFF", "-DGLFW_BUILD_EXAMPLES=OFF", "-DGLFW_INSTALL=OFF");
145-
'ASSIMP' = @("-DASSIMP_BUILD_TESTS=OFF", "-DASSIMP_INSTALL=OFF", "-DASSIMP_BUILD_SAMPLES=OFF", "-DASSIMP_BUILD_ASSIMP_TOOLS=OFF", "-DASSIMP_BUILD_ALL_IMPORTERS_BY_DEFAULT=OFF", "-DASSIMP_BUILD_OBJ_IMPORTER=ON", "-DASSIMP_BUILD_ALL_EXPORTERS_BY_DEFAULT=OFF", "-DASSIMP_BUILD_OBJ_EXPORTER=ON");
146-
'STDUUID' = @("-DUUID_BUILD_TESTS=OFF", "-DUUID_USING_CXX20_SPAN=ON", "-DUUID_SYSTEM_GENERATOR=OFF");
147-
'YAMLCPP' = @("-DYAML_CPP_BUILD_TOOLS=OFF", "-DYAML_CPP_BUILD_TESTS=OFF", "-DYAML_CPP_FORMAT_SOURCE=OFF", "-DYAML_BUILD_SHARED_LIBS=OFF");
148-
'FRAMEWORK' = @("-DBUILD_FRAMEWORK=ON");
149-
'VULKAN_LOADER' = @("-DVULKAN_HEADERS_INSTALL_DIR=$ExternalVulkanHeadersInstallDir", "-DUSE_MASM=OFF", "-DUSE_GAS=OFF")
150-
'SPIRV_TOOLS' = @("-DSPIRV_SKIP_EXECUTABLES=ON", "-DSPIRV_SKIP_TESTS=ON")
151-
'SPIRV_CROSS' = @("-DSPIRV_CROSS_ENABLE_TESTS=OFF")
152-
'LAUNCHER_ONLY' = @("-DLAUNCHER_ONLY=ON")
153-
'GLM' = @("-DCMAKE_POLICY_VERSION_MINIMUM=3.5")
154-
}
155-
156-
$cMakeCacheVariableOverride = $cMakeOptions -join ' '
157-
158-
# Define CMake Generator argument
159-
switch ($systemName) {
160-
"Windows" {
161-
switch ($VsVersion) {
162-
2022 {
163-
$cMakeGenerator = "-G `"Visual Studio 17 2022`" -A $architecture"
164-
}
165-
Default {
166-
throw 'This version of Visual Studio is not supported'
167-
}
168-
}
169-
$cMakeCacheVariableOverride += ' -DCMAKE_CONFIGURATION_TYPES=Debug;Release '
170-
}
171-
"Linux" {
172-
$cMakeGenerator = "-G `"Ninja`""
173-
}
174-
"Darwin" {
175-
$cMakeGenerator = "-G `"Xcode`""
176-
$cMakeCacheVariableOverride += ' ' + $submoduleCMakeOptions.FRAMEWORK -join ' '
177-
}
178-
Default {
179-
throw 'This system is not supported'
180-
}
181-
}
182-
183-
if($LauncherOnly) {
184-
$cMakeCacheVariableOverride += ' ' + $submoduleCMakeOptions.LAUNCHER_ONLY -join ' '
185-
} else {
186-
$cMakeCacheVariableOverride += ' ' + $submoduleCMakeOptions.ENT -join ' '
187-
$cMakeCacheVariableOverride += ' ' + $submoduleCMakeOptions.SPDLOG -join ' '
188-
$cMakeCacheVariableOverride += ' ' + $submoduleCMakeOptions.ASSIMP -join ' '
189-
$cMakeCacheVariableOverride += ' ' + $submoduleCMakeOptions.STDUUID -join ' '
190-
$cMakeCacheVariableOverride += ' ' + $submoduleCMakeOptions.YAMLCPP -join ' '
191-
$cMakeCacheVariableOverride += ' ' + $submoduleCMakeOptions.VULKAN_LOADER -join ' '
192-
$cMakeCacheVariableOverride += ' ' + $submoduleCMakeOptions.SPIRV_CROSS -join ' '
193-
$cMakeCacheVariableOverride += ' ' + $submoduleCMakeOptions.SPIRV_TOOLS -join ' '
194-
$cMakeCacheVariableOverride += ' ' + $submoduleCMakeOptions.GLFW -join ' '
195-
$cMakeCacheVariableOverride += ' ' + $submoduleCMakeOptions.GLM -join ' '
196-
}
120+
$configName = $systemName, $architecture, $configuration -join "_"
197121

198-
$cMakeArguments = " -S $repositoryRootPath -B $buildDirectoryPath $cMakeGenerator $cMakeCacheVariableOverride"
122+
$cMakeArguments = " --preset $configName"
199123

200124
# CMake Generation process
201125
Write-Host $cMakeArguments
@@ -206,18 +130,7 @@ function Build([string]$configuration, [int]$VsVersion , [bool]$runBuild) {
206130

207131
# CMake Build Process
208132
#
209-
if ($runBuild) {
210-
if ($cMakeGenerator -like 'Visual Studio*') {
211-
# With a Visual Studio Generator, `msbuild.exe` is used to run the build. By default, `msbuild.exe` will
212-
# launch worker processes to opportunistically re-use for subsequent builds. To cause the worker processes
213-
# to exit at the end of the main process, pass `-nodeReuse:false`.
214-
$buildToolOptions = '-nodeReuse:false'
215-
}
216-
217-
$buildArguments = "--build $buildDirectoryPath --config $configuration"
218-
if ($buildToolOptions) {
219-
$buildArguments = $buildArguments, $buildToolOptions -join " --"
220-
}
133+
$buildArguments = "--build --preset $configName"
221134

222135
$buildProcess = Start-Process $cMakeProgram -ArgumentList $buildArguments -NoNewWindow -PassThru
223136

@@ -229,7 +142,6 @@ function Build([string]$configuration, [int]$VsVersion , [bool]$runBuild) {
229142
if ($buildProcess.ExitCode -ne 0) {
230143
throw "cmake failed build for '$buildArguments' with exit code '$buildProcess.ExitCode'"
231144
}
232-
}
233145
}
234146

235147

ZEngine/tests/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ file ( GLOB TEST_SOURCES
44
Maths/*.cpp
55
Misc/*.cpp)
66

7-
add_executable(ZEngineTests ${TEST_SOURCES})
7+
add_executable(ZEngineTests)
8+
9+
target_sources(ZEngineTests PRIVATE ${TEST_SOURCES})
810

911
target_link_libraries(ZEngineTests PRIVATE
1012
zEngineLib

0 commit comments

Comments
 (0)