-
Notifications
You must be signed in to change notification settings - Fork 13
/
CMakeLists.txt
222 lines (198 loc) · 9.53 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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
cmake_minimum_required(VERSION 3.8)
project(xray-1.7.0)
if (CMAKE_SIZEOF_VOID_P EQUAL 4)
set(ARCH_X86 TRUE)
else()
set(ARCH_X86 FALSE)
endif()
set(GAME_PATH "" CACHE STRING "path to the game folder, used as output directoy for the engine binaries")
option(BUILD_UTILS "enable utils projects build" OFF)
option(REL_DEVELOP "switch RelWithDebInfo configuration into development mode" OFF)
option(BUILD_TESTS "enable tests projects build" OFF)
option(DEBUG_CAPS "enable debug capabilities" OFF)
option(PNG_SCREENSHOTS "enable png format for the screenshots" OFF)
if ("${GAME_PATH}" STREQUAL "")
message(FATAL_ERROR "Invalid game path")
endif()
configure_file(code/engine/xr_config.h.in ${CMAKE_CURRENT_BINARY_DIR}/generated/xr_config.h @ONLY)
if (MSVC)
if(MSVC_VERSION EQUAL 1912) # MSVS 2017.5
execute_process(COMMAND "vswhere" "-version" "15.5" "-property" "installationPath"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/extras
OUTPUT_VARIABLE VS_TOOLS_PATH
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(VC_ENV_BAT ${VS_TOOLS_PATH}/VC/Auxiliary/Build/vcvarsall.bat)
add_compile_options(/std:c++latest /await /permissive-)
add_compile_options("$<$<CONFIG:RELWITHDEBINFO>:/Oi>")
else()
message(FATAL_ERROR "Only MSVC 15.5 (MSVS 2017) and higher is supported")
endif()
else()
message(FATAL_ERROR "Only MSVC compiler is supported")
endif()
set(CMAKE_CONFIGURATION_TYPES "Debug;RelWithDebInfo" CACHE STRING "" FORCE)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
string(REGEX REPLACE "/EH[a-z]+" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
add_compile_options(/MP "$<$<CONFIG:RELWITHDEBINFO>:/Ob2>" "$<$<CONFIG:DEBUG>:/EHsc>"
"$<$<CONFIG:RELWITHDEBINFO>:/Ot>" "$<$<CONFIG:RELWITHDEBINFO>:/wd4577>")
if (NOT REL_DEVELOP)
add_compile_options("$<$<CONFIG:RELWITHDEBINFO>:/GL>")
endif()
if (ARCH_X86)
add_compile_options("$<$<CONFIG:RELWITHDEBINFO>:/arch:SSE2>")
endif()
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -D_HAS_EXCEPTIONS=0")
if (ARCH_X86)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /LARGEADDRESSAWARE")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LARGEADDRESSAWARE")
endif()
if (REL_DEVELOP)
set(SHARED_RELEASE_LINKER_FLAGS "")
else()
set(SHARED_RELEASE_LINKER_FLAGS "/LTCG /OPT:REF /INCREMENTAL:NO")
endif()
set(STATIC_RELEASE_LINKER_FLAGS "/LTCG")
set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO} ${SHARED_RELEASE_LINKER_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} ${SHARED_RELEASE_LINKER_FLAGS}")
set(CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO} ${STATIC_RELEASE_LINKER_FLAGS}")
unset(SHARED_RELEASE_LINKER_FLAGS)
unset(STATIC_RELEASE_LINKER_FLAGS)
if (ARCH_X86)
set(ARCH_SUFFIX x86)
else()
set(ARCH_SUFFIX x64)
endif()
set(BIN_OUT_PATH ${GAME_PATH}/bin/${ARCH_SUFFIX})
set(PDB_OUT_PATH ${GAME_PATH}/pdb/${ARCH_SUFFIX})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${BIN_OUT_PATH})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${BIN_OUT_PATH})
set(CMAKE_PDB_OUTPUT_DIRECTORY ${PDB_OUT_PATH})
include_directories(code/3rd-party code/engine code/utils ${CMAKE_CURRENT_BINARY_DIR}/generated)
# 3d-party
if (BUILD_TESTS)
set(gtest_force_shared_crt ON)
add_subdirectory(code/3rd-party/gtest)
endif()
add_subdirectory(code/3rd-party/dxsdk)
add_subdirectory(code/3rd-party/zlib)
add_subdirectory(code/3rd-party/minizip)
add_subdirectory(code/3rd-party/dxerr2015)
add_subdirectory(code/3rd-party/ode)
add_subdirectory(code/3rd-party/openal)
add_subdirectory(code/3rd-party/luajit)
add_subdirectory(code/3rd-party/luabind)
add_subdirectory(code/3rd-party/imdexlib)
add_subdirectory(code/3rd-party/libogg)
add_subdirectory(code/3rd-party/libtheora)
add_subdirectory(code/3rd-party/libvorbis)
add_subdirectory(code/3rd-party/libvorbisfile)
add_subdirectory(code/3rd-party/ati)
add_subdirectory(code/3rd-party/nvapi)
add_subdirectory(code/3rd-party/DPlay)
add_subdirectory(code/3rd-party/eax)
add_subdirectory(code/3rd-party/cs)
add_subdirectory(code/3rd-party/fmtlib EXCLUDE_FROM_ALL)
add_subdirectory(code/3rd-party/boost)
if (BUILD_TESTS)
set_target_properties(gmock PROPERTIES FOLDER "3rd-party/gtest")
set_target_properties(gmock_main PROPERTIES FOLDER "3rd-party/gtest")
set_target_properties(gtest PROPERTIES FOLDER "3rd-party/gtest")
set_target_properties(gtest_main PROPERTIES FOLDER "3rd-party/gtest")
endif()
set_target_properties(zlib PROPERTIES FOLDER 3rd-party)
set_target_properties(minizip PROPERTIES FOLDER 3rd-party)
set_target_properties(dxerr2015 PROPERTIES FOLDER 3rd-party)
set_target_properties(ode PROPERTIES FOLDER 3rd-party)
set_target_properties(openal32 PROPERTIES FOLDER 3rd-party)
set_target_properties(luajit-build PROPERTIES FOLDER 3rd-party)
set_target_properties(luabind PROPERTIES FOLDER 3rd-party)
set_target_properties(libogg PROPERTIES FOLDER 3rd-party)
set_target_properties(libtheora PROPERTIES FOLDER 3rd-party)
set_target_properties(libvorbis PROPERTIES FOLDER 3rd-party)
set_target_properties(libvorbisfile PROPERTIES FOLDER 3rd-party)
set_target_properties(ati-src PROPERTIES FOLDER 3rd-party)
set_target_properties(nvapi-src PROPERTIES FOLDER 3rd-party)
set_target_properties(DPlay-src PROPERTIES FOLDER 3rd-party)
set_target_properties(eax-src PROPERTIES FOLDER 3rd-party)
set_target_properties(cs-src PROPERTIES FOLDER 3rd-party)
#engine
add_subdirectory(code/engine/xrCore)
add_subdirectory(code/engine/xrAPI)
add_subdirectory(code/engine/xrCDB)
add_subdirectory(code/engine/xrXMLParser)
add_subdirectory(code/engine/xrSound)
add_subdirectory(code/engine/xrNetServer)
add_subdirectory(code/engine/xrEngine)
add_subdirectory(code/engine/xrCPU_Pipe)
add_subdirectory(code/engine/xrParticles)
add_subdirectory(code/engine/xrPhysics)
add_subdirectory(code/engine/xrGame)
add_subdirectory(code/engine/xrRenderPC_R1)
add_subdirectory(code/engine/xrRenderPC_R2)
add_subdirectory(code/engine/xrRenderPC_R3)
add_subdirectory(code/engine/xrRenderPC_R4)
set_target_properties(xrCore PROPERTIES FOLDER engine)
set_target_properties(xrAPI PROPERTIES FOLDER engine)
set_target_properties(xrCDB PROPERTIES FOLDER engine)
set_target_properties(xrXMLParser PROPERTIES FOLDER engine)
set_target_properties(xrSound PROPERTIES FOLDER engine)
set_target_properties(xrNetServer PROPERTIES FOLDER engine)
set_target_properties(xrEngine PROPERTIES FOLDER engine)
set_target_properties(xrCPU_Pipe PROPERTIES FOLDER engine)
set_target_properties(xrParticles PROPERTIES FOLDER engine)
set_target_properties(xrPhysics PROPERTIES FOLDER engine)
set_target_properties(xrGame PROPERTIES FOLDER engine)
set_target_properties(xrRender_R1 PROPERTIES FOLDER engine)
set_target_properties(xrRender_R2 PROPERTIES FOLDER engine)
set_target_properties(xrRender_R3 PROPERTIES FOLDER engine)
set_target_properties(xrRender_R4 PROPERTIES FOLDER engine)
if (MSVC)
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT xrEngine)
endif()
if (${BUILD_UTILS})
add_subdirectory(code/3rd-party/freeimage/libjpeg)
add_subdirectory(code/3rd-party/freeimage/libjxr)
add_subdirectory(code/3rd-party/freeimage/libopenjpeg)
add_subdirectory(code/3rd-party/freeimage/libpng)
add_subdirectory(code/3rd-party/freeimage/librawlite)
add_subdirectory(code/3rd-party/freeimage/libtiff4)
add_subdirectory(code/3rd-party/freeimage/libwebp)
add_subdirectory(code/3rd-party/freeimage/openexr)
add_subdirectory(code/3rd-party/freeimage/freeimage)
set_target_properties(libjpeg PROPERTIES FOLDER "3rd-party/freeimage")
set_target_properties(libjxr PROPERTIES FOLDER "3rd-party/freeimage")
set_target_properties(libopenjpeg PROPERTIES FOLDER "3rd-party/freeimage")
set_target_properties(libpng PROPERTIES FOLDER "3rd-party/freeimage")
set_target_properties(libraw PROPERTIES FOLDER "3rd-party/freeimage")
set_target_properties(libtiff4 PROPERTIES FOLDER "3rd-party/freeimage")
set_target_properties(libwebp PROPERTIES FOLDER "3rd-party/freeimage")
set_target_properties(openexr PROPERTIES FOLDER "3rd-party/freeimage")
set_target_properties(FreeImage PROPERTIES FOLDER "3rd-party/freeimage")
add_subdirectory(code/utils/ctool)
add_subdirectory(code/utils/xrCompress)
add_subdirectory(code/utils/xrQSlim)
add_subdirectory(code/utils/xrSE_Factory)
add_subdirectory(code/utils/ETools)
add_subdirectory(code/utils/CompressionTest)
add_subdirectory(code/utils/LWO)
add_subdirectory(code/utils/xrAI)
add_subdirectory(code/utils/xrDXT)
add_subdirectory(code/utils/xrLC_Light)
add_subdirectory(code/utils/xrLC_LightStab)
add_subdirectory(code/utils/xrDO_Light)
add_subdirectory(code/utils/xrLC)
set_target_properties(ctool PROPERTIES FOLDER utils)
set_target_properties(xrCompress PROPERTIES FOLDER utils)
set_target_properties(xrQSlim PROPERTIES FOLDER utils)
set_target_properties(xrSE_Factory PROPERTIES FOLDER utils)
set_target_properties(ETools PROPERTIES FOLDER utils)
set_target_properties(CompressionTest PROPERTIES FOLDER utils)
set_target_properties(LWO PROPERTIES FOLDER utils)
set_target_properties(xrAI PROPERTIES FOLDER utils)
set_target_properties(xrDXT PROPERTIES FOLDER utils)
set_target_properties(xrLC_Light PROPERTIES FOLDER utils)
set_target_properties(xrLC_LightStab PROPERTIES FOLDER utils)
set_target_properties(xrDO_Light PROPERTIES FOLDER utils)
set_target_properties(xrLC PROPERTIES FOLDER utils)
endif()