-
Notifications
You must be signed in to change notification settings - Fork 54
/
CMakeLists.txt
185 lines (154 loc) · 6.11 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
cmake_minimum_required(VERSION 3.15)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
include(FeatureSummary)
include(CheckCXXCompilerFlag)
if(NOT DEFINED CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo" FORCE)
endif()
project(VanillaConquer C CXX)
option(BUILD_REMASTERTD "Build Tiberian Dawn remaster dll." OFF)
option(BUILD_REMASTERRA "Build Red Alert remaster dll." OFF)
option(BUILD_VANILLATD "Build Tiberian Dawn executable." ON)
option(BUILD_VANILLARA "Build Red Alert executable." ON)
option(MAP_EDITORTD "Include internal scenario editor in Tiberian Dawn build." OFF)
option(MAP_EDITORRA "Include internal scenario editor in Red Alert build." OFF)
option(NETWORKING "Enable network play." ON)
option(WIN9X "Enable support for Windows 95/98/ME." OFF)
option(DSOUND "Enable DirectSound audio. (deprecated)" OFF)
option(DDRAW "Enable DirectDraw video backend. (deprecated)" OFF)
option(SDL1 "Enable SDL1 video backend." OFF)
option(SDL2 "Enable SDL2 video backend." ON)
option(OPENAL "Enable OpenAL audio backend." ON)
option(BUILD_TESTS "Build unit tests." OFF)
option(BUILD_TOOLS "Build modding utilities." OFF)
option(BUILD_WITH_UBSAN "Build with undefined behavior sanitizer" OFF)
option(BUILD_WITH_ASAN "Build with address sanitizer" OFF)
option(GERMAN "Use German instead of English." OFF)
option(FRENCH "Use French instead of English." OFF)
if(WIN32 OR CMAKE_SYSTEM_NAME STREQUAL "Windows")
option(WIN9X "Enable support for Windows 95/98/ME." OFF)
option(DSOUND "Enable DirectSound audio. (deprecated)" OFF)
option(DDRAW "Enable DirectDraw video backend. (deprecated)" OFF)
add_feature_info(Windows9x WIN9X "Windows 95/98/ME support" OFF)
add_feature_info(DirectSound DSOUND "DirectSound audio backend (deprecated)")
add_feature_info(DirectDraw DDRAW "DirectDraw video backend (deprecated)")
endif()
if(APPLE OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
option(MAKE_BUNDLE "Create a standard app bundle rather than command line program." ON)
add_feature_info(MakeBundle MAKE_BUNDLE "App bundles will be generated")
if(MAKE_BUNDLE)
set(MAKE_BUNDLE_OPTION MACOSX_BUNDLE)
endif()
endif()
add_feature_info(SDL1 SDL1 "SDL1 video backend")
add_feature_info(SDL2 SDL2 "SDL2 video backend")
add_feature_info(OpenAL OPENAL "OpenAL audio backend")
add_feature_info(RemasterTD BUILD_REMASTERTD, "Remastered Tiberian Dawn dll")
add_feature_info(RemasterRA BUILD_REMASTERRA "Remastered Red Alert dll")
add_feature_info(VanillaTD BUILD_VANILLATD "Tiberian Dawn executable")
add_feature_info(VanillaRA BUILD_VANILLARA "Red Alert executable")
add_feature_info(MapEditorTD MAP_EDITORTD "Include internal scenario editor in VanillaTD")
add_feature_info(MapEditorRA MAP_EDITORRA "Include internal scenario editor in VanillaRA")
add_feature_info(Networking NETWORKING "Networking support")
add_feature_info(Tests BUILD_TESTS "Unit tests")
add_feature_info(Tools BUILD_TOOLS "Mod developer tools")
if(NOT BUILD_VANILLATD AND NOT BUILD_VANILLARA)
set(DSOUND OFF)
set(DDRAW OFF)
set(SDL1 OFF)
set(SDL2 OFF)
set(OPENAL OFF)
endif()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_FIND_FRAMEWORK "LAST")
add_definitions(-DTRUE_FALSE_DEFINED)
if(GERMAN)
add_definitions(-DGERMAN)
elseif(FRENCH)
add_definitions(-DFRENCH)
else()
add_definitions(-DENGLISH)
endif()
if(WIN32)
add_definitions(-DWIN32 -D_WINDOWS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE -DNOMINMAX)
set(COMMON_LIBS winmm)
endif()
if(NOT MSVC)
# GCC and Clang don't check new allocations by default while MSVC does.
message(STATUS "Checking whether compiler supports -fcheck-new")
check_cxx_compiler_flag("-Werror -fcheck-new" HAVE_CHECK_NEW)
if(HAVE_CHECK_NEW)
message(STATUS "yes")
list(APPEND VC_CXX_FLAGS -fcheck-new)
else()
message(STATUS "no")
endif()
# Some platforms default to an unsigned char, this fixes that.
message(STATUS "Checking whether compiler supports -fsigned-char")
check_cxx_compiler_flag("-Werror -fsigned-char" HAVE_SIGNED_CHAR)
if(HAVE_SIGNED_CHAR)
message(STATUS "yes")
list(APPEND VC_CXX_FLAGS -fsigned-char)
else()
message(STATUS "no")
endif()
endif()
set(VANILLA_DEFS "")
set(VANILLA_LIBS "")
set(REMASTER_DEFS _USRDLL REMASTER_BUILD)
set(REMASTER_LIBS "")
find_package(ClangFormat)
include(ClangFormat)
if(NOT BUILD_VANILLATD AND MAP_EDITORTD)
message(WARNING "Internal scenario editor requires a Tiberian Dawn executable to be built, but it was not enabled.")
set(BUILD_VANILLATD TRUE)
endif()
if(NOT BUILD_VANILLARA AND MAP_EDITORRA)
message(WARNING "Internal scenario editor requires a Red Alert executable to be built, but it is not enabled.")
set(BUILD_VANILLARA TRUE)
endif()
if(NETWORKING)
list(APPEND VANILLA_DEFS NETWORKING)
if(WIN32)
list(APPEND VANILLA_LIBS ws2_32)
endif()
endif()
if(SDL1)
find_package(SDL REQUIRED)
list(APPEND VANILLA_LIBS ${SDL_LIBRARY})
include_directories(${SDL_INCLUDE_DIR})
# winuser.h defines VK_ macros but it can be prevented
if(WIN32)
add_definitions(-DNOVIRTUALKEYCODES)
endif()
set(DDRAW OFF)
set(SDL2 OFF)
endif()
if(SDL2)
find_package(SDL2 REQUIRED)
list(APPEND VANILLA_LIBS ${SDL2_LIBRARY})
include_directories(${SDL2_INCLUDE_DIR})
# winuser.h defines VK_ macros but it can be prevented
if(WIN32)
add_definitions(-DNOVIRTUALKEYCODES)
endif()
set(DDRAW OFF)
endif()
if(OPENAL)
find_package(OpenAL REQUIRED)
list(APPEND VANILLA_LIBS OpenAL::OpenAL)
set(DSOUND OFF)
endif()
if(BUILD_TESTS)
# Tests need to respect some options so need to occur after the options are set.
enable_testing()
add_subdirectory(tests)
endif()
add_subdirectory(common)
add_subdirectory(tiberiandawn)
add_subdirectory(redalert)
add_subdirectory(tools)
feature_summary(WHAT ENABLED_FEATURES DESCRIPTION "Enabled features:")
feature_summary(WHAT DISABLED_FEATURES DESCRIPTION "Disabled features:")