forked from NVIDIA/Q2RTX
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
209 lines (169 loc) · 6.6 KB
/
CMakeLists.txt
File metadata and controls
209 lines (169 loc) · 6.6 KB
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
#
# ---------- Main ----------------------------------------------
#
# Set minimum requirements.
cmake_minimum_required (VERSION 3.9 VERSION 4.1)
cmake_policy(SET CMP0069 NEW)
####
## Add our own 'module' path.
####
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
####
## Main Project, and Version Number.
####
project(quake2-RTXPerimental)
set(Q2RTX_VERSION_MAJOR 0)
set(Q2RTX_VERSION_MINOR 0)
set(Q2RTX_VERSION_POINT 6)
#
# SET "GLOBAL"! C STANDARD
#
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
#
# Set target specific CXX project property values here, right now all use the same:
#
set( PRJ_CXX_DEFAULT_STANDARD_VERSION 20 )
set( PRJ_CXX_DEFAULT_STANDARD_REQUIRED ON )
set( PRJ_CXX_EXTENSIONS OFF )
set( PRJ_CXX_DEFAULT_SCAN_FOR_MODULES OFF )
#
# ---------- "Git Gut" -----------------------------------------
#
# get short-hash of repository.
execute_process(
COMMAND git rev-parse --short HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE Q2RTX_VERSION_SHA
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# get branch name of repository.
execute_process(
COMMAND git rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE Q2RTX_VERSION_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
#
# ---------- Build Options: ------------------------------------
#
OPTION(CONFIG_BUILD_CLIENT_TARGET "Build the Client target" ON)
OPTION(CONFIG_BUILD_SERVER_TARGET "Build the Dedicated Server target" ON)
# WID: This one is unmaintained, but could be updated by someone if desired. For now it is OFF, disabled, does not build anyway.
OPTION(CONFIG_BUILD_GAME_BASEQ2_TARGETS "Build the BaseQ2 Game Module targets( Project is out of dated so, not supported )" OFF)
OPTION(CONFIG_BUILD_GAME_BASEQ2RTXP_TARGETS "Build the BaseQ2RTXP Game Module targets" ON)
OPTION(CONFIG_VKPT_RENDERER "Enable VKPT renderer" ON)
OPTION(CONFIG_VKPT_ENABLE_DEVICE_GROUPS "Enable device groups (multi-gpu) support" ON)
OPTION(CONFIG_VKPT_ENABLE_IMAGE_DUMPS "Enable image dumping functionality" OFF)
OPTION(CONFIG_GL_RENDERER "Enable GL renderer" ON)
OPTION(CONFIG_USE_CURL "Use CURL for HTTP support" ON)
OPTION(CONFIG_BUILD_FTEQW_IQM_TOOL "Build the fteqw-iqmtool target" ON)
OPTION(CONFIG_BUILD_DEV_MATHS_VERIFIER "Build a verifier for the 4x4 mat maths" ON)
if (MSVC)
OPTION(CONFIG_BUILD_WITH_EDIT_AND_CONTINUE "Build with Edit and Continue support (MSVC only)" ON)
endif()
# WIN32: Expect it to be installed by developer instead.
IF( CONFIG_BUILD_CLIENT_TARGET )
IF(WIN32)
SET(DEFAULT_BUILD_GLSLANG OFF)
ELSE()
SET(DEFAULT_BUILD_GLSLANG ON)
ENDIF()
ENDIF() #IF( CONFIG_BUILD_CLIENT_TARGET )
OPTION(CONFIG_BUILD_GLSLANG "Build glslangValidator from source instead of using the SDK" ${DEFAULT_BUILD_GLSLANG})
OPTION(CONFIG_BUILD_IPO "Enable interprocedural optimizations" OFF)
OPTION(CONFIG_BUILD_SHADER_DEBUG_INFO "Build shaders with debug info" OFF)
#OPTION(CONFIG_LINUX_PACKAGING_SUPPORT "Enable Linux Packaging support" OFF)
#OPTION(CONFIG_LINUX_PACKAGING_SKIP_PKZ "Skip zipping the game contents into .pkz when packaging (for quicker iteration)" OFF)
#OPTION(CONFIG_LINUX_STEAM_RUNTIME_SUPPORT "Enable Linux Steam Runtime support" OFF)
#
# ---------- Set USE_FOLDERS globally --------------------------
#
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
#
# ---------- Check for Inter Procedural Optimisations ----------
#
include(CheckIPOSupported)
IF(CONFIG_BUILD_IPO)
check_ipo_supported(RESULT result OUTPUT output)
if(result)
MESSAGE(STATUS "Enabled interprocedural optimizations")
else()
MESSAGE(STATUS "Interprocedural optimizations not supported: ${output}")
SET(CONFIG_BUILD_IPO OFF)
endif()
ENDIF()
#
# ---------- Setup output Directories --------------------------
#
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY
${PROJECT_BINARY_DIR}/Bin
CACHE PATH
"Single Directory for all Libraries"
)
#
# --------- Setup the Executable output Directory --------------
#
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Bin CACHE PATH "Single Directory for all Executables.")
#
# --------- 64 Bits Check --------------------------------------
#
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
set( IS_64_BIT 1 )
endif ()
#
# --------- 'MSVC' Build Flag Management ------------
#
IF(MSVC)
macro(replace_msvcrt var value)
# Remove the existing /MD-type flags, if any
string(REGEX REPLACE "/M[TD]d?\\s*" "" ${var} ${${var}})
# Append the new flag
set(${var} "${${var}} ${value}")
endmacro(replace_msvcrt)
replace_msvcrt(CMAKE_C_FLAGS_DEBUG "/MDd")
replace_msvcrt(CMAKE_C_FLAGS_MINSIZEREL "/MT")
replace_msvcrt(CMAKE_C_FLAGS_RELEASE "/MT")
replace_msvcrt(CMAKE_C_FLAGS_RELWITHDEBINFO "/MT")
# Enable multi-processor compilation when using MSBuild
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP")
# Also adjust C++ flags, needed for 3rd party code
replace_msvcrt(CMAKE_CXX_FLAGS_DEBUG "/MDd")
replace_msvcrt(CMAKE_CXX_FLAGS_MINSIZEREL "/MT")
replace_msvcrt(CMAKE_CXX_FLAGS_RELEASE "/MT")
replace_msvcrt(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/MT")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
IF(CONFIG_BUILD_WITH_EDIT_AND_CONTINUE)
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<$<CONFIG:Debug,RelWithDebInfo>:EditAndContinue>")
message(STATUS "Building with Edit and Continue support")
ELSE()
#message(STATUS "Building without Edit and Continue support")
ENDIF()
ELSEIF(CMAKE_SYSTEM_PROCESSOR STREQUAL "ppc64le")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mcpu=native")
ELSEIF(CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse2 -mfpmath=sse")
ENDIF()
#
# --------- Add 'External' libraries subdirectory --------------
#
# Work around CMAKE_INSTALL_PREFIX being a relative directory when using -B
# on Windows, which in turn trips up 'file(RELATIVE_PATH ...)' used in SDL2
set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/extern/install)
add_subdirectory(extern)
link_directories(.)
#
# --------- Add 'Project' sources subdirectory -----------------
#
# First include the specific sources. (Put in a separate file to organize things a bit. )
include( ${CMAKE_CURRENT_SOURCE_DIR}/CMakeSources.cmake )
set(CMAKE_INSTALL_PREFIX ${PROJECT_BINARY_DIR}/install)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ${CONFIG_BUILD_IPO})
add_subdirectory(src)
#
# --------- Add 'Tools' sources subdirectory -----------------
#
# First include the specific sources. (Put in a separate file to organize things a bit. )
#set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_SOURCE_DIR}/tools)
#set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ${CONFIG_BUILD_IPO})
#add_subdirectory(tools)