Skip to content

Commit 1a78595

Browse files
authored
Implement options to control building internal and debug code. (#441)
Adds additional configure presets to build these on vc6. Adds an additional config for loading into Visual Studio without breaking ninja.
1 parent b1f1ae3 commit 1a78595

File tree

9 files changed

+159
-66
lines changed

9 files changed

+159
-66
lines changed

CMakeLists.txt

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ endif()
3333
# Top level project, doesn't really affect anything.
3434
project(genzh LANGUAGES C CXX)
3535

36+
# Create PDB for Release as long as debug info was generated during compile.
37+
if(MSVC)
38+
string(APPEND CMAKE_EXE_LINKER_FLAGS_RELEASE " /DEBUG /OPT:REF /OPT:ICF")
39+
string(APPEND CMAKE_SHARED_LINKER_FLAGS_RELEASE " /DEBUG /OPT:REF /OPT:ICF")
40+
endif()
41+
3642
include(FetchContent)
3743

3844
# Find/Add build dependencies and stubs shared by all projects
@@ -51,15 +57,11 @@ add_subdirectory(Dependencies/Benchmark)
5157
add_subdirectory(Dependencies/SafeDisc)
5258
add_subdirectory(Dependencies/MaxSDK)
5359

54-
# EA Compression library, shared between games (diff is comments only)
55-
#add_subdirectory(GeneralsMD/Code/Libraries/Source/Compression)
56-
57-
# BrowserDispatch COM object interface (No difference)
58-
#add_subdirectory(GeneralsMD/Code/Libraries/Source/EABrowserDispatch)
59-
6060
# Do we want to build extra SDK stuff or just the game binary?
6161
option(GENZH_BUILD_ZEROHOUR "Build Zero Hour code." ON)
6262
option(GENZH_BUILD_GENERALS "Build Generals code." ON)
63+
option(GENZH_BUILD_INTERNAL "Build code with the \"Internal\" configuration." OFF)
64+
option(GENZH_BUILD_PROFILE "Build code with the \"Profile\" configuration." OFF)
6365

6466
if(NOT GENZH_BUILD_ZEROHOUR AND NOT GENZH_BUILD_GENERALS)
6567
set(GENZH_BUILD_ZEROHOUR TRUE)
@@ -68,6 +70,27 @@ endif()
6870

6971
add_feature_info(ZeroHourStuff GENZH_BUILD_ZEROHOUR "Build Zero Hour code")
7072
add_feature_info(GeneralsStuff GENZH_BUILD_GENERALS "Build Generals code")
73+
add_feature_info(InternalBuild GENZH_BUILD_INTERNAL "Building as an \"Internal\" build")
74+
add_feature_info(ProfileBuild GENZH_BUILD_PROFILE "Building as a \"Profile\" build")
75+
76+
add_library(gz_config INTERFACE)
77+
78+
target_compile_options(gz_config INTERFACE ${GENZH_FLAGS})
79+
80+
target_compile_definitions(gz_config INTERFACE $<IF:$<CONFIG:Debug>,_DEBUG WWDEBUG DEBUG,_RELEASE>)
81+
82+
# This disables a lot of warnings steering developers to use windows only functions/function names.
83+
if(MSVC)
84+
target_compile_definitions(gz_config INTERFACE _CRT_NONSTDC_NO_WARNINGS _CRT_SECURE_NO_WARNINGS)
85+
endif()
86+
87+
if(GENZH_BUILD_PROFILE)
88+
target_compile_definitions(gz_config INTERFACE _PROFILE)
89+
endif()
90+
91+
if(GENZH_BUILD_INTERNAL)
92+
target_compile_definitions(gz_config INTERFACE _INTERNAL)
93+
endif()
7194

7295
# Add main build targets
7396
if(GENZH_BUILD_ZEROHOUR)

CMakePresets.json

Lines changed: 84 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,47 @@
88
"configurePresets": [
99
{
1010
"name": "vc6",
11-
"displayName": "Build Zero Hour Binaries with NMake",
11+
"displayName": "Build Binaries with NMake",
1212
"generator": "NMake Makefiles",
1313
"hidden": false,
1414
"binaryDir": "${sourceDir}/build/${presetName}",
1515
"cacheVariables": {
1616
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
17-
"CMAKE_MSVC_RUNTIME_LIBRARY": "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL",
17+
"CMAKE_MSVC_RUNTIME_LIBRARY": "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL",
18+
"CMAKE_MSVC_DEBUG_INFORMATION_FORMAT": "$<$<CONFIG:Release,Debug,RelWithDebInfo>:ProgramDatabase>",
1819
"CMAKE_BUILD_TYPE": "Release",
1920
"GENZH_FLAGS": "/W3"
2021
}
2122
},
23+
{
24+
"name": "vc6prof",
25+
"displayName": "Build Profiling Binaries with NMake",
26+
"hidden": false,
27+
"inherits": "vc6",
28+
"cacheVariables": {
29+
"GENZH_BUILD_PROFILE": "ON"
30+
}
31+
},
32+
{
33+
"name": "vc6int",
34+
"displayName": "Build Internal Binaries with NMake",
35+
"inherits": "vc6",
36+
"cacheVariables": {
37+
"GENZH_BUILD_INTERNAL": "ON"
38+
}
39+
},
40+
{
41+
"name": "vc6debug",
42+
"displayName": "Build Debug Binaries with NMake",
43+
"hidden": false,
44+
"inherits": "vc6",
45+
"cacheVariables": {
46+
"CMAKE_BUILD_TYPE": "Debug"
47+
}
48+
},
2249
{
2350
"name": "default",
24-
"displayName": "Default Config",
51+
"displayName": "Default Config (don't use directly!)",
2552
"generator": "Ninja Multi-Config",
2653
"hidden": true,
2754
"binaryDir": "${sourceDir}/build/${presetName}",
@@ -32,9 +59,43 @@
3259
}
3360
},
3461
{
35-
"name": "win32",
62+
"name": "msvc32",
3663
"architecture": "Win32",
3764
"inherits": "default",
65+
"generator": "Visual Studio 17 2022",
66+
"hidden": false,
67+
"displayName": "Visual Studio Win32 build",
68+
"cacheVariables": {
69+
"GENZH_FLAGS": "/W3"
70+
}
71+
},
72+
{
73+
"name": "msvc32prof",
74+
"inherits": "msvc32",
75+
"displayName": "Visual Studio Win32 Profile build",
76+
"cacheVariables": {
77+
"GENZH_BUILD_PROFILE": "ON"
78+
}
79+
},
80+
{
81+
"name": "msvc32int",
82+
"inherits": "msvc32",
83+
"displayName": "Visual Studio Win32 Internal build",
84+
"cacheVariables": {
85+
"GENZH_BUILD_INTERNAL": "ON"
86+
}
87+
},
88+
{
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",
3899
"hidden": false,
39100
"displayName": "Win32 build",
40101
"cacheVariables": {
@@ -53,6 +114,12 @@
53114
}
54115
],
55116
"buildPresets": [
117+
{
118+
"name": "vc6",
119+
"configurePreset": "vc6",
120+
"displayName": "Build VC6 Windows build",
121+
"description": "Build VC6 Windows build"
122+
},
56123
{
57124
"name": "win32",
58125
"configurePreset": "win32",
@@ -69,6 +136,19 @@
69136
}
70137
],
71138
"workflowPresets": [
139+
{
140+
"name": "vc6",
141+
"steps": [
142+
{
143+
"type": "configure",
144+
"name": "vc6"
145+
},
146+
{
147+
"type": "build",
148+
"name": "vc6"
149+
}
150+
]
151+
},
72152
{
73153
"name": "win32",
74154
"steps": [

Generals/Code/GameEngine/CMakeLists.txt

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,14 @@ set(GAMEENGINE_SRC
10581058
)
10591059

10601060
add_library(g_gameengine STATIC)
1061-
set_target_properties(g_gameengine PROPERTIES OUTPUT_NAME $<IF:$<CONFIG:Debug>,gameenginedebug,gameengine>)
1061+
1062+
if(GENZH_BUILD_DEBUG)
1063+
set_target_properties(g_gameengine PROPERTIES OUTPUT_NAME gameenginedebug)
1064+
elseif(GENZH_BUILD_INTERNAL)
1065+
set_target_properties(g_gameengine PROPERTIES OUTPUT_NAME gameengineinternal)
1066+
else()
1067+
set_target_properties(g_gameengine PROPERTIES OUTPUT_NAME gameengine)
1068+
endif()
10621069

10631070
target_sources(g_gameengine PRIVATE ${GAMEENGINE_SRC})
10641071

@@ -1079,19 +1086,11 @@ target_link_libraries(g_gameengine PUBLIC
10791086
g_browserdispatch
10801087
g_compression
10811088
g_wwvegas
1089+
gz_config
10821090
gamespy::gamespy
10831091
stlport
10841092
)
10851093

1086-
target_compile_options(g_gameengine INTERFACE
1087-
${GENZH_FLAGS}
1088-
)
1089-
10901094
target_compile_definitions(g_gameengine PRIVATE
10911095
IG_DEBUG_STACKTRACE
10921096
)
1093-
1094-
target_compile_definitions(g_gameengine PUBLIC
1095-
$<$<CONFIG:Debug>:_DEBUG>
1096-
$<$<CONFIG:Debug>:DEBUG>
1097-
)

Generals/Code/Libraries/Source/WWVegas/CMakeLists.txt

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,9 @@
11
# Interface libraries to set common defines and includes, avoid duplication later
22
add_library(g_wwcommon INTERFACE)
33

4-
target_compile_definitions(g_wwcommon INTERFACE
5-
#NOMINMAX
6-
WIN32_LEAN_AND_MEAN
7-
$<$<CONFIG:Debug>:WWDEBUG>
8-
$<$<CONFIG:Debug>:_DEBUG>
9-
)
10-
11-
target_compile_options(g_wwcommon INTERFACE
12-
${WARNING_FLAGS}
13-
)
14-
154
target_link_libraries(g_wwcommon INTERFACE
165
d3d8lib
6+
gz_config
177
milesstub
188
stlport
199
)

Generals/Code/Tools/WW3D/max2w3d/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ target_link_libraries(g_max2w3d PRIVATE
164164
# The headers typedef INT_PTR to different types, but maxsdk expects it
165165
# typedef'ed to int, otherwise throws linker errors.
166166
d3d8lib
167+
g_pluglib
167168
maxsdk
168-
pluglib
169169
winmm
170170
)
171171

GeneralsMD/Code/GameEngine/CMakeLists.txt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,6 +1143,14 @@ set(GAMEENGINE_SRC
11431143
add_library(z_gameengine STATIC)
11441144
set_target_properties(z_gameengine PROPERTIES OUTPUT_NAME $<IF:$<CONFIG:Debug>,gameenginedebug,gameengine>)
11451145

1146+
if(GENZH_BUILD_DEBUG)
1147+
set_target_properties(z_gameengine PROPERTIES OUTPUT_NAME gameenginedebug)
1148+
elseif(GENZH_BUILD_INTERNAL)
1149+
set_target_properties(z_gameengine PROPERTIES OUTPUT_NAME gameengineinternal)
1150+
else()
1151+
set_target_properties(z_gameengine PROPERTIES OUTPUT_NAME gameengine)
1152+
endif()
1153+
11461154
target_sources(z_gameengine PRIVATE ${GAMEENGINE_SRC})
11471155

11481156
target_include_directories(z_gameengine PUBLIC
@@ -1161,21 +1169,13 @@ target_link_libraries(z_gameengine PRIVATE
11611169
target_link_libraries(z_gameengine PUBLIC
11621170
d3d8lib
11631171
gamespy::gamespy
1172+
gz_config
11641173
stlport
11651174
z_browserdispatch
11661175
z_compression
11671176
z_wwvegas
11681177
)
11691178

1170-
target_compile_options(z_gameengine INTERFACE
1171-
${GENZH_FLAGS}
1172-
)
1173-
11741179
target_compile_definitions(z_gameengine PRIVATE
11751180
IG_DEBUG_STACKTRACE
11761181
)
1177-
1178-
target_compile_definitions(z_gameengine PUBLIC
1179-
$<$<CONFIG:Debug>:_DEBUG>
1180-
$<$<CONFIG:Debug>:DEBUG>
1181-
)

GeneralsMD/Code/Libraries/Source/WWVegas/CMakeLists.txt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,11 @@ add_library(z_wwcommon INTERFACE)
44
target_compile_definitions(z_wwcommon INTERFACE
55
#NOMINMAX
66
WIN32_LEAN_AND_MEAN
7-
$<$<CONFIG:Debug>:WWDEBUG>
8-
$<$<CONFIG:Debug>:_DEBUG>
9-
)
10-
11-
target_compile_options(z_wwcommon INTERFACE
12-
${GENZH_FLAGS}
137
)
148

159
target_link_libraries(z_wwcommon INTERFACE
1610
d3d8lib
11+
gz_config
1712
milesstub
1813
stlport
1914
)
Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
set(PROFILE_SRC
2-
"profile_funclevel.cpp"
3-
"profile_funclevel.h"
4-
"profile_highlevel.cpp"
5-
"profile_highlevel.h"
6-
"profile_result.cpp"
7-
"profile_result.h"
8-
"_pch.cpp"
9-
"_pch.h"
10-
"internal.h"
11-
"internal_cmd.h"
12-
"internal_funclevel.h"
13-
"internal_highlevel.h"
14-
"internal_result.h"
15-
"profile.cpp"
16-
"profile.h"
17-
"profile_cmd.cpp"
18-
"profile_doc.h"
2+
"profile_funclevel.cpp"
3+
"profile_funclevel.h"
4+
"profile_highlevel.cpp"
5+
"profile_highlevel.h"
6+
"profile_result.cpp"
7+
"profile_result.h"
8+
"_pch.cpp"
9+
"_pch.h"
10+
"internal.h"
11+
"internal_cmd.h"
12+
"internal_funclevel.h"
13+
"internal_highlevel.h"
14+
"internal_result.h"
15+
"profile.cpp"
16+
"profile.h"
17+
"profile_cmd.cpp"
18+
"profile_doc.h"
1919
)
2020

2121
add_library(z_profile STATIC)
@@ -31,4 +31,10 @@ target_link_libraries(z_profile PRIVATE
3131
zi_libraries_include
3232
)
3333

34-
set_target_properties(z_profile PROPERTIES OUTPUT_NAME $<IF:$<CONFIG:Debug>,profiledebug,profile>)
34+
if(GENZH_BUILD_DEBUG)
35+
set_target_properties(z_profile PROPERTIES OUTPUT_NAME profiledebug)
36+
elseif(GENZH_BUILD_INTERNAL)
37+
set_target_properties(z_profile PROPERTIES OUTPUT_NAME profileinternal)
38+
else()
39+
set_target_properties(z_profile PROPERTIES OUTPUT_NAME profile)
40+
endif()

GeneralsMD/Code/Tools/WW3D/max2w3d/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ target_link_libraries(z_max2w3d PRIVATE
165165
# typedef'ed to int, otherwise throws linker errors.
166166
d3d8lib
167167
maxsdk
168-
pluglib
169168
winmm
169+
z_pluglib
170170
)
171171

172172
set_target_properties(z_max2w3d PROPERTIES LINK_FLAGS "/DEF:max2w3d.def")

0 commit comments

Comments
 (0)