Skip to content

Commit cc43bc3

Browse files
committed
[CMake] Refactor CMake build config options. (#498)
1 parent 8caba67 commit cc43bc3

File tree

3 files changed

+162
-41
lines changed

3 files changed

+162
-41
lines changed

.github/workflows/build-games.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ jobs:
5757
tools: true
5858
- preset: "vc6int"
5959
tools: true
60-
- preset: "vc6debug"
60+
- preset: "vc6dbg"
6161
tools: true
6262
fail-fast: false
6363
uses: ./.github/workflows/toolchain-common.yml
@@ -80,7 +80,7 @@ jobs:
8080
tools: true
8181
- preset: "vc6int"
8282
tools: true
83-
- preset: "vc6debug"
83+
- preset: "vc6dbg"
8484
tools: true
8585
fail-fast: false
8686
uses: ./.github/workflows/toolchain-common.yml

CMakeLists.txt

+13-9
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ option(GENZH_BUILD_ZEROHOUR "Build Zero Hour code." ON)
6464
option(GENZH_BUILD_GENERALS "Build Generals code." ON)
6565
option(GENZH_BUILD_INTERNAL "Build code with the \"Internal\" configuration." OFF)
6666
option(GENZH_BUILD_PROFILE "Build code with the \"Profile\" configuration." OFF)
67+
option(GENZH_BUILD_DEBUG "Build code with the \"Debug\" configuration." OFF)
6768

6869
if(NOT GENZH_BUILD_ZEROHOUR AND NOT GENZH_BUILD_GENERALS)
6970
set(GENZH_BUILD_ZEROHOUR TRUE)
@@ -74,6 +75,7 @@ add_feature_info(ZeroHourStuff GENZH_BUILD_ZEROHOUR "Build Zero Hour code")
7475
add_feature_info(GeneralsStuff GENZH_BUILD_GENERALS "Build Generals code")
7576
add_feature_info(InternalBuild GENZH_BUILD_INTERNAL "Building as an \"Internal\" build")
7677
add_feature_info(ProfileBuild GENZH_BUILD_PROFILE "Building as a \"Profile\" build")
78+
add_feature_info(DebugBuild GENZH_BUILD_DEBUG "Building as a \"Debug\" build")
7779

7880
add_library(gz_config INTERFACE)
7981

@@ -84,19 +86,21 @@ endif()
8486

8587
target_compile_options(gz_config INTERFACE ${GENZH_FLAGS})
8688

87-
target_compile_definitions(gz_config INTERFACE $<IF:$<CONFIG:Debug>,_DEBUG WWDEBUG DEBUG,_RELEASE>)
88-
8989
# This disables a lot of warnings steering developers to use windows only functions/function names.
9090
if(MSVC)
91-
target_compile_definitions(gz_config INTERFACE _CRT_NONSTDC_NO_WARNINGS _CRT_SECURE_NO_WARNINGS)
92-
endif()
93-
94-
if(GENZH_BUILD_PROFILE)
95-
target_compile_definitions(gz_config INTERFACE _PROFILE)
91+
target_compile_definitions(gz_config INTERFACE _CRT_NONSTDC_NO_WARNINGS _CRT_SECURE_NO_WARNINGS $<$<CONFIG:DEBUG>:_DEBUG_CRT>)
9692
endif()
9793

98-
if(GENZH_BUILD_INTERNAL)
99-
target_compile_definitions(gz_config INTERFACE _INTERNAL)
94+
if(GENZH_BUILD_DEBUG)
95+
target_compile_definitions(gz_config INTERFACE _DEBUG WWDEBUG DEBUG)
96+
else()
97+
target_compile_definitions(gz_config INTERFACE _RELEASE)
98+
99+
if(GENZH_BUILD_INTERNAL)
100+
target_compile_definitions(gz_config INTERFACE _INTERNAL)
101+
elseif(GENZH_BUILD_PROFILE)
102+
target_compile_definitions(gz_config INTERFACE _PROFILE)
103+
endif()
100104
endif()
101105

102106
# Add main build targets

CMakePresets.json

+147-30
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818
"CMAKE_MSVC_DEBUG_INFORMATION_FORMAT": "$<$<CONFIG:Release,Debug,RelWithDebInfo>:ProgramDatabase>",
1919
"CMAKE_BUILD_TYPE": "Release",
2020
"GENZH_FLAGS": "/W3"
21+
},
22+
"vendor": {
23+
"jetbrains.com/clion": {
24+
"toolchain": "Visual Studio 6"
25+
}
2126
}
2227
},
2328
{
@@ -38,12 +43,13 @@
3843
}
3944
},
4045
{
41-
"name": "vc6debug",
46+
"name": "vc6dbg",
4247
"displayName": "Build Debug Binaries with NMake",
4348
"hidden": false,
4449
"inherits": "vc6",
4550
"cacheVariables": {
46-
"CMAKE_BUILD_TYPE": "Debug"
51+
"CMAKE_BUILD_TYPE": "Debug",
52+
"GENZH_BUILD_DEBUG": "ON"
4753
}
4854
},
4955
{
@@ -59,58 +65,52 @@
5965
}
6066
},
6167
{
62-
"name": "msvc32",
63-
"architecture": "Win32",
68+
"name": "win32",
6469
"inherits": "default",
65-
"generator": "Visual Studio 17 2022",
6670
"hidden": false,
67-
"displayName": "Visual Studio Win32 build",
71+
"displayName": "Windows 32bit build",
72+
"architecture": {
73+
"value": "Win32",
74+
"strategy": "external"
75+
},
6876
"cacheVariables": {
6977
"GENZH_FLAGS": "/W3"
78+
},
79+
"vendor": {
80+
"jetbrains.com/clion": {
81+
"toolchain": "Visual Studio"
82+
}
7083
}
7184
},
7285
{
73-
"name": "msvc32prof",
74-
"inherits": "msvc32",
75-
"displayName": "Visual Studio Win32 Profile build",
86+
"name": "win32prof",
87+
"inherits": "win32",
88+
"displayName": "Windows 32bit Profile build",
7689
"cacheVariables": {
7790
"GENZH_BUILD_PROFILE": "ON"
7891
}
7992
},
8093
{
81-
"name": "msvc32int",
82-
"inherits": "msvc32",
83-
"displayName": "Visual Studio Win32 Internal build",
94+
"name": "win32int",
95+
"inherits": "win32",
96+
"displayName": "Windows 32bit Internal build",
8497
"cacheVariables": {
8598
"GENZH_BUILD_INTERNAL": "ON"
8699
}
87100
},
88101
{
89-
"name": "msvc32debug",
90-
"inherits": "msvc32",
91-
"displayName": "Visual Studio Win32 Debug build",
92-
"cacheVariables": {
93-
"CMAKE_BUILD_TYPE": "Debug"
94-
}
95-
},
96-
{
97-
"name": "win32",
98-
"inherits": "default",
99-
"hidden": false,
100-
"displayName": "Win32 build",
102+
"name": "win32dbg",
103+
"inherits": "win32",
104+
"displayName": "Windows 32bit Debug build",
101105
"cacheVariables": {
102-
"GENZH_FLAGS": "/W3"
106+
"GENZH_BUILD_DEBUG": "ON"
103107
}
104108
},
105109
{
106110
"name": "unix",
107111
"inherits": "default",
108112
"hidden": false,
109-
"displayName": "Non-Windows build",
110-
"cacheVariables": {
111-
"CMAKE_CXX_FLAGS_RELEASE": "-O2 -g -DNDEBUG",
112-
"CMAKE_C_FLAGS_RELEASE": "-O2 -g -DNDEBUG"
113-
}
113+
"displayName": "Non-Windows build"
114114
}
115115
],
116116
"buildPresets": [
@@ -120,13 +120,52 @@
120120
"displayName": "Build VC6 Windows build",
121121
"description": "Build VC6 Windows build"
122122
},
123+
{
124+
"name": "vc6int",
125+
"configurePreset": "vc6int",
126+
"displayName": "Build VC6 Windows Internal build",
127+
"description": "Build VC6 Windows Internal build"
128+
},
129+
{
130+
"name": "vc6prof",
131+
"configurePreset": "vc6prof",
132+
"displayName": "Build VC6 Windows Profile build",
133+
"description": "Build VC6 Windows Profile build"
134+
},
135+
{
136+
"name": "vc6dbg",
137+
"configurePreset": "vc6dbg",
138+
"displayName": "Build VC6 Windows Debug build",
139+
"description": "Build VC6 Windows Debug build"
140+
},
123141
{
124142
"name": "win32",
125143
"configurePreset": "win32",
126144
"displayName": "Build Windows build",
127145
"description": "Build Windows build",
128146
"configuration": "Release"
129147
},
148+
{
149+
"name": "win32int",
150+
"configurePreset": "win32int",
151+
"displayName": "Build Windows Internal build",
152+
"description": "Build Windows Internal build",
153+
"configuration": "Release"
154+
},
155+
{
156+
"name": "win32prof",
157+
"configurePreset": "win32prof",
158+
"displayName": "Build Windows Profiling build",
159+
"description": "Build Windows Profiling build",
160+
"configuration": "Release"
161+
},
162+
{
163+
"name": "win32dbg",
164+
"configurePreset": "win32dbg",
165+
"displayName": "Build Windows Debug build",
166+
"description": "Build Windows Debug build",
167+
"configuration": "Debug"
168+
},
130169
{
131170
"name": "unix",
132171
"configurePreset": "unix",
@@ -149,6 +188,45 @@
149188
}
150189
]
151190
},
191+
{
192+
"name": "vc6dbg",
193+
"steps": [
194+
{
195+
"type": "configure",
196+
"name": "vc6dbg"
197+
},
198+
{
199+
"type": "build",
200+
"name": "vc6dbg"
201+
}
202+
]
203+
},
204+
{
205+
"name": "vc6int",
206+
"steps": [
207+
{
208+
"type": "configure",
209+
"name": "vc6int"
210+
},
211+
{
212+
"type": "build",
213+
"name": "vc6int"
214+
}
215+
]
216+
},
217+
{
218+
"name": "vc6prof",
219+
"steps": [
220+
{
221+
"type": "configure",
222+
"name": "vc6prof"
223+
},
224+
{
225+
"type": "build",
226+
"name": "vc6prof"
227+
}
228+
]
229+
},
152230
{
153231
"name": "win32",
154232
"steps": [
@@ -162,6 +240,45 @@
162240
}
163241
]
164242
},
243+
{
244+
"name": "win32int",
245+
"steps": [
246+
{
247+
"type": "configure",
248+
"name": "win32int"
249+
},
250+
{
251+
"type": "build",
252+
"name": "win32int"
253+
}
254+
]
255+
},
256+
{
257+
"name": "win32prof",
258+
"steps": [
259+
{
260+
"type": "configure",
261+
"name": "win32prof"
262+
},
263+
{
264+
"type": "build",
265+
"name": "win32prof"
266+
}
267+
]
268+
},
269+
{
270+
"name": "win32dbg",
271+
"steps": [
272+
{
273+
"type": "configure",
274+
"name": "win32dbg"
275+
},
276+
{
277+
"type": "build",
278+
"name": "win32dbg"
279+
}
280+
]
281+
},
165282
{
166283
"name": "unix",
167284
"steps": [

0 commit comments

Comments
 (0)