-
Notifications
You must be signed in to change notification settings - Fork 81
/
CMakeLists.txt
234 lines (193 loc) · 8.68 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
223
224
225
226
227
228
229
230
231
232
233
234
cmake_minimum_required(VERSION 3.14)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE STRING "")
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.14" CACHE STRING "Minimum OS X deployment version")
# CMake 3.22 changes cmake_dependent_option from doing `if(${CONDITION})` to actually evaulating
# The cmake code `if(<condition>)` using cmake_language(EVAL). That's a breaking change that warns
# if we don't explicitly set the policy. We prefer the OLD policy to avoid surprises. The NEW policy
# would let us use parens, eg `[[FOO AND (BAR OR MEOW)]]`.
if(POLICY CMP0127)
cmake_policy(SET CMP0127 OLD)
endif()
include(CMakeDependentOption)
include(Dependencies)
include(FeatureSummary)
include(MetalShaderSupport)
include(VcpkgToolchain)
project(Plasma)
# Set up Product Identification parameters
set(PRODUCT_BRANCH_ID "1" CACHE STRING "Branch ID")
set(PRODUCT_BUILD_ID "918" CACHE STRING "Build ID")
set(PRODUCT_BUILD_TYPE "50" CACHE STRING "Build Type")
set(PRODUCT_CORE_NAME "UruLive" CACHE STRING "Product Core Name")
set(PRODUCT_SHORT_NAME "UruLive" CACHE STRING "Product Short Name")
set(PRODUCT_LONG_NAME "Uru Live" CACHE STRING "Product Long Name")
set(PRODUCT_UUID "ea489821-6c35-4bd0-9dae-bb17c585e680"
CACHE STRING "Product UUID")
option(PRODUCT_EMBED_BUILD_INFO "Embed build revision information into plProduct" ON)
cmake_dependent_option(PRODUCT_EMBED_BUILD_TIME "Embed build time into plProduct" ON [[PRODUCT_EMBED_BUILD_INFO]] OFF)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set(CMAKE_FOLDER "CMakePredefinedTargets")
# HeadSpin Configuration
# Define HS_DEBUGGING for debug builds
add_compile_definitions($<$<CONFIG:Debug>:HS_DEBUGGING>)
if(WIN32 AND NOT CYGWIN)
add_definitions(-DHS_BUILD_FOR_WIN32)
endif(WIN32 AND NOT CYGWIN)
if(UNIX)
# This is set for both Linux and Mac builds
add_definitions(-DHS_BUILD_FOR_UNIX)
endif(UNIX)
if(APPLE)
add_definitions(-DHS_BUILD_FOR_APPLE)
set(CMAKE_XCODE_GENERATE_SCHEME FALSE)
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
add_definitions(-DHS_BUILD_FOR_MACOS)
option(PLASMA_MAC_UNIVERSAL "Build macOS multi-architecture universal builds?" OFF)
if (PLASMA_MAC_UNIVERSAL)
set(CMAKE_OSX_ARCHITECTURES "$(ARCHS_STANDARD)")
endif()
if(CMAKE_SYSTEM_VERSION VERSION_LESS 10) # Darwin 10 == Mac OS X 10.6
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
endif()
endif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
endif(APPLE)
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
add_definitions(-DHS_BUILD_FOR_LINUX)
endif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
# End HeadSpin Configuration
# Custom configuration for Release (optimized) with PDBs
if(MSVC)
if(NOT "RelWithPDB" IN_LIST CMAKE_CONFIGURATION_TYPES)
set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES};RelWithPDB" CACHE STRING "" FORCE)
endif()
# Yeah, this looks strange. The semicolon is to establish an empty list item
# for the configuration-less import.
set(CMAKE_MAP_IMPORTED_CONFIG_RELWITHPDB "Release;")
# Need /Zi for the PDB
set(CMAKE_C_FLAGS_RELWITHPDB "${CMAKE_C_FLAGS_RELEASE} /Zi" CACHE STRING "")
set(CMAKE_CXX_FLAGS_RELWITHPDB "${CMAKE_CXX_FLAGS_RELEASE} /Zi" CACHE STRING "")
set(CMAKE_EXE_LINKER_FLAGS_RELWITHPDB "/INCREMENTAL:NO /DEBUG:FULL /OPT:REF,NOICF" CACHE STRING "")
set(CMAKE_MODULE_LINKER_FLAGS_RELWITHPDB "/INCREMENTAL:NO /DEBUG:FULL /OPT:REF,NOICF" CACHE STRING "")
set(CMAKE_RC_FLAGS_RELWITHPDB "" CACHE STRING "")
set(CMAKE_SHARED_LINKER_FLAGS_RELWITHPDB "/INCREMENTAL:NO /DEBUG:FULL /OPT:REF,NOICF" CACHE STRING "")
set(CMAKE_STATIC_LINKER_FLAGS_RELWITHPDB "" CACHE STRING "")
mark_as_advanced(
CMAKE_C_FLAGS_RELWITHPDB CMAKE_CXX_FLAGS_REL_WITHPDB CMAKE_EXE_LINKER_FLAGS_RELWITHPDB
CMAKE_MODULE_LINKER_FLAGS_RELWITHPDB CMAKE_RC_FLAGS_RELWITHPDB CMAKE_SHARED_LINKER_FLAGS_RELWITHPDB
CMAKE_STATIC_LINKER_FLAGS_RELWITHPDB
)
endif()
# End custom release configuration
# Find all 3rd-party libraries that are required
find_package(ASIO 1.14 REQUIRED)
find_package(CURL REQUIRED)
find_package(DirectX)
find_package(epoxy)
find_package(expat REQUIRED)
find_package(freetype REQUIRED)
find_package(JPEG REQUIRED)
find_package(libwebm)
find_package(Ogg REQUIRED)
find_package(OpenAL REQUIRED)
find_package(OpenSSL REQUIRED)
find_package(Opus)
find_package(PhysX REQUIRED)
find_package(PNG REQUIRED)
find_package(Python3 3.8 REQUIRED COMPONENTS Interpreter Development)
find_package(Speex)
find_package(string_theory 3.4 REQUIRED)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads REQUIRED)
find_package(Vorbis REQUIRED)
find_package(VPX)
find_package(ZLIB REQUIRED)
if(APPLE)
find_package(Security)
find_package(Metal)
find_package(LibArchive REQUIRED)
elseif(UNIX)
find_package(LIBSECRET)
find_package(Uuid REQUIRED)
find_package(Fontconfig REQUIRED)
elseif(WIN32)
if(PLASMA_BUILD_MAX_PLUGIN STREQUAL "REQUIRED")
set(_3dsm_FIND_ARG "REQUIRED")
endif()
find_package(3dsm ${_3dsm_FIND_ARG})
find_package(VLD)
endif()
include(PythonUtils)
include(PlasmaTargets)
option(PLASMA_EXTERNAL_RELEASE "Is this release intended for the general public?" OFF)
if(PLASMA_EXTERNAL_RELEASE)
add_definitions(-DPLASMA_EXTERNAL_RELEASE)
endif(PLASMA_EXTERNAL_RELEASE)
# Pipeline Renderers
cmake_dependent_option(PLASMA_PIPELINE_DX "Enable DirectX rendering pipeline?" ON "DirectX_FOUND" OFF)
cmake_dependent_option(PLASMA_PIPELINE_GL "Enable OpenGL rendering pipeline?" ON "TARGET epoxy::epoxy" OFF)
cmake_dependent_option(PLASMA_PIPELINE_METAL "Enable Metal rendering pipeline?" ON "TARGET Metal::Metal" OFF)
if(PLASMA_PIPELINE_DX)
add_definitions(-DPLASMA_PIPELINE_DX)
endif(PLASMA_PIPELINE_DX)
if(PLASMA_PIPELINE_GL)
add_definitions(-DPLASMA_PIPELINE_GL)
endif(PLASMA_PIPELINE_GL)
if(PLASMA_PIPELINE_METAL)
add_definitions(-DPLASMA_PIPELINE_METAL)
enable_language(Metal)
endif(PLASMA_PIPELINE_METAL)
# Allow us to disable certain parts of the build
option(PLASMA_BUILD_CLIENT "Do we want to build plClient?" ON)
cmake_dependent_option(PLASMA_BUILD_MAX_PLUGIN "Do we want to build the 3ds Max plugin?" OFF "TARGET 3dsm AND NOT PLASMA_EXTERNAL_RELEASE" OFF)
option(PLASMA_BUILD_LAUNCHER "Do we want to build plUruLauncher?" ON)
option(PLASMA_BUILD_TOOLS "Do we want to build the Plasma tools?" ON)
option(PLASMA_BUILD_TESTS "Do we want to build the unit tests?" OFF)
option(PLASMA_STACK_WALKER "Do we want to use the stack walker for crash handling?" ON)
cmake_dependent_option(USE_EFX "Use EFX for environmental audio effects" ON "OPENAL_HAS_EFX" OFF)
cmake_dependent_option(USE_EGL "Use EGL for OpenGL rendering" ON "epoxy_HAS_EGL" OFF)
cmake_dependent_option(USE_OPUS "Use Opus audio for voice chat" ON "TARGET Opus::opus" OFF)
cmake_dependent_option(USE_SPEEX "Use Speex audio for voice chat" ON "TARGET Speex::speex" OFF)
cmake_dependent_option(USE_VPX "Use VPX for movie support" ON "TARGET VPX::VPX" OFF)
cmake_dependent_option(USE_WEBM "Use WebM movie player" ON "TARGET Opus::opus AND TARGET libwebm::libwebm AND USE_VPX" OFF)
cmake_dependent_option(USE_VLD "Build and link with Visual Leak Detector" OFF "TARGET VLD::VLD" OFF)
# Configure compile-time compiler-specific flags and other config files
include(cmake/CompilerChecks.cmake)
configure_file("${PROJECT_SOURCE_DIR}/cmake/hsConfig.h.cmake" "${PROJECT_BINARY_DIR}/hsConfig.h")
include_directories(${PROJECT_BINARY_DIR})
if(PLASMA_BUILD_TOOLS)
# Custom dummy target for compiling all tools
add_custom_target(tools)
set_target_properties(tools PROPERTIES XCODE_GENERATE_SCHEME TRUE)
endif()
include(TestBigEndian)
test_big_endian(BIG_ENDIAN)
if(BIG_ENDIAN)
add_definitions(-DHS_BIG_ENDIAN)
endif()
if(MSVC)
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
add_definitions(-D_SCL_SECURE_NO_DEPRECATE)
endif(MSVC)
set(PLASMA_SOURCE_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/Sources/Plasma")
set(PLASMA_TOOLS_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/Sources/Tools")
set(PLASMA_MAX_PLUGIN_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/Sources/MaxPlugin")
add_subdirectory(Sources/Plasma)
add_subdirectory(Scripts)
if(PLASMA_BUILD_MAX_PLUGIN)
add_subdirectory(Sources/MaxPlugin)
endif()
if(PLASMA_BUILD_TESTS)
enable_testing()
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>)
add_subdirectory(Sources/Tests EXCLUDE_FROM_ALL)
endif(PLASMA_BUILD_TESTS)
if(PLASMA_BUILD_TOOLS)
add_subdirectory(Sources/Tools)
endif()
# This must be called only after all Qt targets are declared
plasma_deploy_qt()
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)