Skip to content

Commit 994093e

Browse files
committed
Implements CMake build system. (#365)
Pulls most dependencies via FetchContent.
1 parent f4f66ec commit 994093e

File tree

139 files changed

+7557
-4
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

139 files changed

+7557
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,4 @@ thumbs.db
4343
/.cache
4444
.clang-format
4545
/.vscode
46+
/Dependencies/MaxSDK/maxsdk

CMakeLists.txt

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
cmake_minimum_required(VERSION 3.25)
2+
3+
# Use packagename_ROOT for FindPackage.
4+
if(POLICY CMP0074)
5+
cmake_policy(SET CMP0074 NEW)
6+
endif()
7+
8+
# Disable default MSVC setting CRT type so we can set it ourselves.
9+
if(POLICY CMP0091)
10+
cmake_policy(SET CMP0091 NEW)
11+
endif()
12+
13+
# Disable default MSVC warning level so we can set it ourselves.
14+
if(POLICY CMP0092)
15+
cmake_policy(SET CMP0092 NEW)
16+
endif()
17+
18+
# Allow specifying MSVC debug configurations.
19+
#if(POLICY CMP0141)
20+
# cmake_policy(SET CMP0141 NEW)
21+
#endif()
22+
23+
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
24+
25+
include(FeatureSummary)
26+
include(CMakeDependentOption)
27+
28+
# We don't support in tree builds, so help people make the right choice.
29+
if (CMAKE_BINARY_DIR STREQUAL CMAKE_SOURCE_DIR)
30+
message(FATAL_ERROR "Building in-source is not supported! Create a build dir and remove ${CMAKE_SOURCE_DIR}/CMakeCache.txt")
31+
endif()
32+
33+
# Top level project, doesn't really affect anything.
34+
project(genzh LANGUAGES C CXX)
35+
36+
include(FetchContent)
37+
38+
# Find/Add build dependencies and stubs shared by all projects
39+
if((WIN32 OR "${CMAKE_SYSTEM}" MATCHES "Windows") AND ${CMAKE_SIZEOF_VOID_P} EQUAL 4)
40+
include(cmake/miles.cmake)
41+
include(cmake/bink.cmake)
42+
include(cmake/stlport.cmake)
43+
include(cmake/dx8.cmake)
44+
include(cmake/dbghelp.cmake)
45+
endif()
46+
47+
include(cmake/gamespy.cmake)
48+
include(cmake/lzhl.cmake)
49+
include(cmake/zlib.cmake)
50+
add_subdirectory(Dependencies/Benchmark)
51+
add_subdirectory(Dependencies/SafeDisc)
52+
add_subdirectory(Dependencies/MaxSDK)
53+
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+
60+
# Do we want to build extra SDK stuff or just the game binary?
61+
option(GENZH_BUILD_ZEROHOUR "Build Zero Hour code." ON)
62+
option(GENZH_BUILD_GENERALS "Build Generals code." ON)
63+
64+
if(NOT GENZH_BUILD_ZEROHOUR AND NOT GENZH_BUILD_GENERALS)
65+
set(GENZH_BUILD_ZEROHOUR TRUE)
66+
message("You must select one project to build, building Zero Hour by default.")
67+
endif()
68+
69+
add_feature_info(ZeroHourStuff GENZH_BUILD_ZEROHOUR "Build Zero Hour code")
70+
add_feature_info(GeneralsStuff GENZH_BUILD_GENERALS "Build Generals code")
71+
72+
# Add main build targets
73+
if(GENZH_BUILD_ZEROHOUR)
74+
add_subdirectory(GeneralsMD)
75+
endif()
76+
77+
if(GENZH_BUILD_GENERALS)
78+
add_subdirectory(Generals)
79+
endif()
80+
81+
feature_summary(WHAT ENABLED_FEATURES DESCRIPTION "Enabled features:")
82+
feature_summary(WHAT DISABLED_FEATURES DESCRIPTION "Disabled features:")

CMakePresets.json

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
{
2+
"version": 6,
3+
"cmakeMinimumRequired": {
4+
"major": 3,
5+
"minor": 25,
6+
"patch": 0
7+
},
8+
"configurePresets": [
9+
{
10+
"name": "vc6",
11+
"displayName": "Build Zero Hour Binaries with NMake",
12+
"generator": "NMake Makefiles",
13+
"hidden": false,
14+
"binaryDir": "${sourceDir}/build/${presetName}",
15+
"cacheVariables": {
16+
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
17+
"CMAKE_MSVC_RUNTIME_LIBRARY": "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL",
18+
"CMAKE_BUILD_TYPE": "Release",
19+
"GENZH_FLAGS": "/W3"
20+
}
21+
},
22+
{
23+
"name": "default",
24+
"displayName": "Default Config",
25+
"generator": "Ninja Multi-Config",
26+
"hidden": true,
27+
"binaryDir": "${sourceDir}/build/${presetName}",
28+
"cacheVariables": {
29+
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
30+
"CMAKE_MSVC_DEBUG_INFORMATION_FORMAT": "$<$<CONFIG:Release,Debug,RelWithDebInfo>:Embedded>",
31+
"CMAKE_MSVC_RUNTIME_LIBRARY": "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL"
32+
}
33+
},
34+
{
35+
"name": "win32",
36+
"architecture": "Win32",
37+
"inherits": "default",
38+
"hidden": false,
39+
"displayName": "Win32 build",
40+
"cacheVariables": {
41+
"GENZH_FLAGS": "/W3"
42+
}
43+
},
44+
{
45+
"name": "unix",
46+
"inherits": "default",
47+
"hidden": false,
48+
"displayName": "Non-Windows build",
49+
"cacheVariables": {
50+
"CMAKE_CXX_FLAGS_RELEASE": "-O2 -g -DNDEBUG",
51+
"CMAKE_C_FLAGS_RELEASE": "-O2 -g -DNDEBUG"
52+
}
53+
}
54+
],
55+
"buildPresets": [
56+
{
57+
"name": "win32",
58+
"configurePreset": "win32",
59+
"displayName": "Build Windows build",
60+
"description": "Build Windows build",
61+
"configuration": "Release"
62+
},
63+
{
64+
"name": "unix",
65+
"configurePreset": "unix",
66+
"displayName": "Build non-Windows build",
67+
"description": "Build non-Windows build",
68+
"configuration": "Release"
69+
}
70+
],
71+
"workflowPresets": [
72+
{
73+
"name": "win32",
74+
"steps": [
75+
{
76+
"type": "configure",
77+
"name": "win32"
78+
},
79+
{
80+
"type": "build",
81+
"name": "win32"
82+
}
83+
]
84+
},
85+
{
86+
"name": "unix",
87+
"steps": [
88+
{
89+
"type": "configure",
90+
"name": "unix"
91+
},
92+
{
93+
"type": "build",
94+
"name": "unix"
95+
}
96+
]
97+
}
98+
]
99+
}

Dependencies/Benchmark/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
cmake_minimum_required(VERSION 3.5.0)
2+
3+
project(benchmark VERSION 1.0.0 LANGUAGES C)
4+
5+
add_library(benchmark INTERFACE)
6+
target_include_directories(benchmark INTERFACE
7+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
8+
)

Dependencies/Benchmark/benchmark.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#pragma once
2+
3+
// Cheeky stub that just returns "good" results.
4+
inline int RunBenchmark(int argc, char *argv[], float *floatResult, float *intResult, float *memResult)
5+
{
6+
if (floatResult) {
7+
*floatResult = 10.0f;
8+
}
9+
10+
if (intResult) {
11+
*intResult = 10.0f;
12+
}
13+
14+
if (memResult) {
15+
*memResult = 10.0f;
16+
}
17+
18+
return 1;
19+
}

Dependencies/MaxSDK/CMakeLists.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/maxsdk AND IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/maxsdk)
2+
message("MaxSDK has been provided, 3d Studio Max plugins can be built.")
3+
add_library(maxsdk INTERFACE)
4+
target_include_directories(maxsdk INTERFACE maxsdk/Include maxsdk/Include/Maxscrpt)
5+
target_link_directories(maxsdk INTERFACE maxsdk/Lib)
6+
target_link_libraries(maxsdk INTERFACE
7+
bmm
8+
core
9+
geom
10+
Maxscrpt
11+
maxutil
12+
mesh
13+
Paramblk2
14+
)
15+
else()
16+
message("MaxSDK has not been provided, 3d Studio Max plugins cannot be built.")
17+
endif()

Dependencies/MaxSDK/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# 3D Studio Max SDK
2+
3+
The 3D Studio Max SDK is required to build the W3D plugin. Currently this plugin is only for an old version of 3DS Max and as such should be considered for reference only. The SDK license is incompatible with GPLv3 so we do not supply the SDK and do not distribute the plugin that can be built.
4+
5+
If you wish to enable building the plugin locally, you can do so by providing the 4.2.0 Max SDK in this folder. It can be obtained from The Internet Archive [here](https://archive.org/details/maxsdk-4.2.0.85). Download the zip and unzip it to this folder. This should result in this folder containing this file (README.md), the CMake build file providing configuration information to use the SDK (CMakeLists.txt) and the SDK folder extracted from the zip (maxsdk). When you build the project, provided building development tools is enabled, a max plugin "max2w3d.dle" will be produced.

Dependencies/SafeDisc/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
add_library(safedisc INTERFACE)
2+
target_include_directories(safedisc INTERFACE .)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#pragma once
2+
3+
// Fake macros to keep WinMain happy.
4+
5+
#define CDAPFN_DECLARE_GLOBAL(x, y, z)
6+
#define CDAPFN_ENDMARK(x) ((void)0)

Dependencies/SafeDisc/ReadMe.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
The two copies are intentional, because the game references two paths:
2+
3+
"Common/SafeDisc/CdaPfn.h"
4+
"SafeDisk/CdaPfn.h"

0 commit comments

Comments
 (0)