forked from overte-org/overte
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
323 lines (273 loc) · 12.8 KB
/
CMakeLists.txt
File metadata and controls
323 lines (273 loc) · 12.8 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
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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
# Copyright 2013-2019 High Fidelity, Inc.
# Copyright 2019-2021 Vircadia contributors.
# Copyright 2020-2025 Overte e.V.
# SPDX-License-Identifier: Apache-2.0
# As the official CMake documentation is pretty bad for non-experts, Craig Scott's "Professional CMake: A Practical Guide" is a worthwhile investment,
# both as a guide and as a reference manual. https://crascit.com/professional-cmake/
# This should allow using long paths on Windows
SET(CMAKE_NINJA_FORCE_RESPONSE_FILE 1 CACHE INTERNAL "")
# 3.24 is the minimum version that supports CMAKE_COMPILE_WARNING_AS_ERROR
cmake_minimum_required(VERSION 3.24)
# Avoid CMP0177 policy warning introduced in CMake 3.31.
cmake_policy(VERSION 3.24...3.31)
include(SelectLibraryConfigurations)
# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON)
# Instruct CMake to run rcc automatically when needed
set(CMAKE_AUTORCC ON)
# set our OS X deployment target
if (APPLE)
# Needs to be set before the first project() call.
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.11" CACHE STRING "Specifies the minimum version of the target platform (e.g. macOS or iOS) on which the target binaries are to be deployed.")
endif()
project(overte)
include("cmake/init.cmake")
include("cmake/compiler.cmake")
# Guard against missing `-falign-functions`.
if( NOT WIN32 )
# Function alignment is necessary for V8 scripting engine! We will run into random crashes otherwise.
# SetAlignedPointerInInternalField requires at least 2 byte alignment and -falign-functions will set alignment
# to machine specific value which should be greater than 2.
string(FIND "${CMAKE_CXX_FLAGS}" "-falign-functions" falign-functions_INDEX)
if(${falign-functions_INDEX} EQUAL -1)
# Substring not found
message(FATAL_ERROR "CMAKE_CXX_FLAGS is missing -falign-functions. This is required to avoid crashes in relation to the V8 scripting engine and should have been set by Conan.")
endif()
endif()
# QT_NO_DEBUG isn't being defined on Windows, so we do that here.
add_compile_definitions($<$<CONFIG:Release>:QT_NO_DEBUG>)
add_compile_definitions($<$<CONFIG:RelWithDebInfo>:QT_NO_DEBUG>)
#
# OVERTE_WARNINGS
#
# Here we add the ability to allowlist warnings we've determined we can't fix, or are safe to
# ignore for one reason or another. The way of doing so is compiler-specific, so we deal with
# the detection of that in cmake, and just pass it down to the code from here.
#
# We can also treat warnings as errors. Without the allowlist this will almost certainly lead
# to a build failure.
set(OVERTE_WARNINGS_ALLOWLIST ON CACHE BOOL "Allowlist some warnings we can't currently fix.")
if(OVERTE_WARNINGS_ALLOWLIST)
if (NOT WIN32)
set(CMAKE_PLATFORM_INFO_DIR "${CMAKE_CURRENT_BINARY_DIR}")
include(CMakeDetermineCXXCompiler)
endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
message(STATUS "GCC compiler detected, suppressing some unsolvable warnings.")
add_compile_definitions(OVERTE_WARNINGS_ALLOWLIST_GCC)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
message(STATUS "Clang compiler detected, suppressing some unsolvable warnings.")
add_compile_definitions(OVERTE_WARNINGS_ALLOWLIST_CLANG)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC" OR (CMAKE_CXX_COMPILER_ID MATCHES "" AND WIN32))
message(STATUS "Microsoft Visual Studio compiler detected, suppressing some unsolvable warnings.")
add_compile_definitions(OVERTE_WARNINGS_ALLOWLIST_MSVC)
else()
message(NOTICE "We don't know yet how to allowlist warnings for ${CMAKE_CXX_COMPILER_ID}")
endif()
endif()
#
# Overte build variables
#
set(OVERTE_BUILD_CLIENT ON CACHE BOOL "Build Interface.")
set(OVERTE_BUILD_SERVER ON CACHE BOOL "Build domain-server, assignment-client, and ice-server.")
set(OVERTE_BUILD_TESTS OFF CACHE BOOL "Build tests.")
set(OVERTE_BUILD_MANUAL_TESTS OFF CACHE BOOL "Build manual tests.")
set(OVERTE_BUILD_TOOLS ON CACHE BOOL "Build tools. Includes Oven, which is used for some server functionality.")
set(OVERTE_BUILD_INSTALLER ON CACHE BOOL "Build installer.")
set(OVERTE_DISABLE_QML OFF CACHE BOOL "Build without QML. (For graphics debugging.)")
set(OVERTE_DOWNLOAD_SERVERLESS_CONTENT OFF CACHE BOOL "Download and setup default serverless content beside Interface.")
# use OpenGL ES on Linux aarch64 and Android.
if ((CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64") OR ANDROID)
set(OVERTE_RENDERING_BACKEND "GLES" CACHE STRING "Which rendering backend to compile with. Valid options are: 'OpenGL', 'GLES', and 'Vulkan'.")
else()
set(OVERTE_RENDERING_BACKEND "OpenGL" CACHE STRING "Which rendering backend to compile with. Valid options are: 'OpenGL', 'GLES', and 'Vulkan'.")
endif()
set(OVERTE_EXTERNAL_BUILD_ASSETS "https://build-deps.overte.org" CACHE INTERNAL "")
set(OVERTE_TIMESERVER_URL "http://timestamp.comodoca.com?td=sha256" CACHE STRING "URL to timeserver used for signing executables.")
set(OVERTE_USE_OPTIMIZED_IK OFF CACHE BOOL "Use optimized IK.")
set(OVERTE_DISABLE_KTX_CACHE OFF CACHE BOOL "Disable KTX Cache.")
set(OVERTE_USE_KHR_ROBUSTNESS OFF CACHE BOOL "Use KHR_robustness.")
set(OVERTE_BACKTRACE_URL "" CACHE STRING "URL to an endpoint for uploading crash-dumps. For example Sentry.")
set(OVERTE_BACKTRACE_TOKEN "" CACHE STRING "Token used to identify this build, for use in uploading crash-dumps.")
if (ANDROID OR UWP)
set(OVERTE_BUILD_SERVER OFF CACHE BOOL FORCE "Overwritten (mobile build)")
set(OVERTE_BUILD_TOOLS OFF CACHE BOOL FORCE "Overwritten (mobile build)")
set(OVERTE_BUILD_INSTALLER OFF CACHE BOOL FORCE "Overwritten (mobile build)")
endif()
if (ANDROID)
set(PLATFORM_QT_COMPONENTS AndroidExtras WebView)
add_definitions(-DHIFI_ANDROID_APP=\"${HIFI_ANDROID_APP}\")
if (
(${HIFI_ANDROID_APP} STREQUAL "questInterface") OR
(${HIFI_ANDROID_APP} STREQUAL "questFramePlayer") OR
(${HIFI_ANDROID_APP} STREQUAL "framePlayer")
)
# We know the quest hardware has this extension, so we can force the use of instanced stereo
add_definitions(-DHAVE_EXT_clip_cull_distance)
# We can also use multiview stereo techniques
add_definitions(-DHAVE_OVR_multiview2)
add_definitions(-DHAVE_OVR_multiview)
# We can also use our own foveated textures
add_definitions(-DHAVE_QCOM_texture_foveated)
# if set, the application itself or some library it depends on MUST implement
# `DisplayPluginList getDisplayPlugins()` and `InputPluginList getInputPlugins()`
add_definitions(-DCUSTOM_INPUT_PLUGINS)
add_definitions(-DCUSTOM_DISPLAY_PLUGINS)
set(PLATFORM_PLUGIN_LIBRARIES oculusMobile oculusMobilePlugin)
endif()
# Allow client code to use preprocessor macros to distinguish between quest and non-quest builds
if (${HIFI_ANDROID_APP} STREQUAL "questInterface")
add_definitions(-DANDROID_APP_QUEST_INTERFACE)
elseif(${HIFI_ANDROID_APP} STREQUAL "interface")
add_definitions(-DANDROID_APP_INTERFACE)
endif()
else ()
set(PLATFORM_QT_COMPONENTS WebEngine Xml)
endif()
if (OVERTE_USE_KHR_ROBUSTNESS)
add_definitions(-DUSE_KHR_ROBUSTNESS)
endif()
if (OVERTE_RENDERING_BACKEND STREQUAL "GLES")
add_definitions(-DUSE_GLES)
add_definitions(-DUSE_GL)
add_definitions(-DGPU_POINTER_STORAGE_SHARED)
set(PLATFORM_GL_BACKEND gpu-gl-common gpu-gles)
elseif (OVERTE_RENDERING_BACKEND STREQUAL "OpenGL")
add_definitions(-DGPU_POINTER_STORAGE_RAW)
add_definitions(-DUSE_GL)
set(PLATFORM_GL_BACKEND gpu-gl-common gpu-gl)
elseif (OVERTE_RENDERING_BACKEND STREQUAL "Vulkan")
add_definitions(-DGPU_POINTER_STORAGE_RAW)
# TODO: remove dependencies on gl libraries for Vulkan builds.
set(PLATFORM_GL_BACKEND gpu-gl-common gpu-gl gpu-vk vk)
# Vulkan is the default rendering backend, no need to set any flags.
else()
message(FATAL_ERROR "Invalid OVERTE_RENDERING_BACKEND set. Expected 'GLES', 'OpenGL', or 'Vulkan'. Got '${OVERTE_RENDERING_BACKEND}'")
endif()
foreach(PLATFORM_QT_COMPONENT ${PLATFORM_QT_COMPONENTS})
list(APPEND PLATFORM_QT_LIBRARIES "Qt5::${PLATFORM_QT_COMPONENT}")
endforeach()
message(STATUS "Use optimized IK: " ${OVERTE_USE_OPTIMIZED_IK})
message(STATUS "Build server: " ${OVERTE_BUILD_SERVER})
message(STATUS "Build client: " ${OVERTE_BUILD_CLIENT})
message(STATUS "Build tests: " ${OVERTE_BUILD_TESTS})
message(STATUS "Build tools: " ${OVERTE_BUILD_TOOLS})
message(STATUS "Build installer: " ${OVERTE_BUILD_INSTALLER})
message(STATUS "Rendering backend: " ${OVERTE_RENDERING_BACKEND})
message(STATUS "DL serverless content: " ${OVERTE_DOWNLOAD_SERVERLESS_CONTENT})
if (OVERTE_DISABLE_QML)
message(STATUS "QML disabled!")
add_definitions(-DDISABLE_QML)
endif()
if (OVERTE_DISABLE_KTX_CACHE)
message(STATUS "KTX cache disabled!")
add_definitions(-DDISABLE_KTX_CACHE)
endif()
if (UNIX AND DEFINED ENV{HIFI_MEMORY_DEBUGGING})
MESSAGE(STATUS "Memory debugging is enabled")
endif()
# Set SERVER_ONLY and CLIENT_ONLY for later packaging.
if ((NOT OVERTE_BUILD_CLIENT) AND OVERTE_BUILD_SERVER)
set(SERVER_ONLY ON CACHE BOOL INTERNAL "")
elseif ((NOT OVERTE_BUILD_SERVER) AND OVERTE_BUILD_CLIENT)
set(CLIENT_ONLY ON CACHE BOOL INTERNAL "")
endif()
#
# Helper projects
#
file(GLOB_RECURSE CMAKE_SRC cmake/*.cmake cmake/CMakeLists.txt)
add_custom_target(cmake SOURCES ${CMAKE_SRC})
GroupSources("cmake")
unset(CMAKE_SRC)
file(GLOB_RECURSE JS_SRC scripts/*.* unpublishedScripts/*.*)
add_custom_target(js SOURCES ${JS_SRC})
GroupSources("scripts")
GroupSources("unpublishedScripts")
unset(JS_SRC)
# Include Overte Web app files if cloned into a subdirectory.
if (IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/overte-web")
file(GLOB_RECURSE WEB_APP_SRC overte-web/*.*)
list(FILTER WEB_APP_SRC EXCLUDE REGEX "overte-web/(dist|node_modules|public)/*" )
overte(overte-web SOURCES ${WEB_APP_SRC})
GroupSources("overte-web")
unset(WEB_APP_SRC)
endif()
# Include Overte Web SDK files if cloned into a subdirectory.
if (IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/overte-web-sdk")
file(GLOB_RECURSE WEB_SDK_SRC overte-web-sdk/*.*)
list(FILTER WEB_SDK_SRC EXCLUDE REGEX "overte-web-sdk/(dist|node_modules|public)/*" )
add_custom_target(overte-web-sdk SOURCES ${WEB_SDK_SRC})
GroupSources("overte-web-sdk")
unset(WEB_SDK_SRC)
endif()
set_packaging_parameters()
find_package( Threads )
add_definitions(-DGLM_FORCE_RADIANS)
add_definitions(-DGLM_ENABLE_EXPERIMENTAL)
add_definitions(-DGLM_FORCE_CTOR_INIT)
if (OVERTE_USE_OPTIMIZED_IK)
message(STATUS "Setting definition for using optimized inverse kinematics.")
add_definitions(-DHIFI_USE_OPTIMIZED_IK)
endif()
set(HIFI_LIBRARY_DIR "${CMAKE_CURRENT_SOURCE_DIR}/libraries")
set(EXTERNAL_PROJECT_PREFIX "project")
set_property(DIRECTORY PROPERTY EP_PREFIX ${EXTERNAL_PROJECT_PREFIX})
setup_externals_binary_dir()
set(OVERTE_USE_NSIGHT ON CACHE BOOL "Attempt to find the Nvidia nSight libraries.")
# FIXME hack to work on the proper Android toolchain
if (ANDROID)
add_subdirectory(android/apps/${HIFI_ANDROID_APP})
return()
endif()
if (BUILD_GPU_FRAME_PLAYER_ONLY)
# This is for CI build testing
add_subdirectory(tools/gpu-frame-player)
else()
# OVERTE_BUILD_TOOLS option will be handled inside the tools's CMakeLists.txt because 'scribe' tool is required for build anyway
add_subdirectory(tools)
# add subdirectories for all targets
if (OVERTE_BUILD_SERVER)
add_subdirectory(assignment-client)
set_target_properties(assignment-client PROPERTIES FOLDER "Apps")
add_subdirectory(domain-server)
set_target_properties(domain-server PROPERTIES FOLDER "Apps")
add_subdirectory(ice-server)
set_target_properties(ice-server PROPERTIES FOLDER "Apps")
endif()
if (OVERTE_BUILD_CLIENT)
add_subdirectory(interface)
if (APPLE)
set_target_properties(Overte PROPERTIES FOLDER "Apps")
else()
set_target_properties(interface PROPERTIES FOLDER "Apps")
endif()
option(USE_SIXENSE "Build Interface with sixense library/plugin" OFF)
option(USE_NEURON "Build Interface with Neuron library/plugin" OFF)
endif()
if (OVERTE_BUILD_CLIENT OR OVERTE_BUILD_SERVER)
add_subdirectory(plugins)
add_subdirectory(server-console)
endif()
endif()
if (OVERTE_BUILD_TESTS)
# Turn on testing so that add_test works
# MUST be in the root cmake file for ctest to work
include(CTest)
enable_testing()
add_subdirectory(tests)
if (OVERTE_BUILD_MANUAL_TESTS)
add_subdirectory(tests-manual)
endif()
endif()
if (OVERTE_BUILD_INSTALLER)
if (UNIX)
install(
DIRECTORY "${CMAKE_SOURCE_DIR}/scripts"
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/interface
COMPONENT ${CLIENT_COMPONENT}
)
endif()
generate_installers()
endif()
# QML import paths for Qt Creator and KDevelop code completion
set(QML_IMPORT_PATH ${CMAKE_SOURCE_DIR}/interface/resources/qml;${CMAKE_SOURCE_DIR}/launchers/qt/resources/qml CACHE PATH "Extra QML import paths for KDevelop and Qt Creator")