-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathCMakeLists.txt
327 lines (272 loc) · 9.25 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
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
324
325
326
327
# ------------------------------------------------------------------------------------------------ #
# This file is part of CosmoScout VR #
# ------------------------------------------------------------------------------------------------ #
# SPDX-FileCopyrightText: German Aerospace Center (DLR) <[email protected]>
# SPDX-License-Identifier: MIT
cmake_minimum_required(VERSION 3.13)
project(cosmoscout-vr VERSION 1.10.0)
# Use cmake 3.12's <PACKAGE>_ROOT variabled for searching.
cmake_policy(SET CMP0074 NEW)
# Ensure local modules (for dependencies etc.) are found.
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
# CMAKE_BUILD_TYPE must be set (except for Visual Studio).
if(NOT MSVC)
if(NOT CMAKE_BUILD_TYPE OR
(NOT ${CMAKE_BUILD_TYPE} STREQUAL "Release" AND
NOT ${CMAKE_BUILD_TYPE} STREQUAL "Debug"))
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Release or Debug" FORCE)
endif()
endif()
# Use folders when targeting an IDE
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# find dependencies --------------------------------------------------------------------------------
include(GenerateExportHeader)
# Boost and OpenGL must be present on your system. All other dependencies are included as submodules
# in "externals/". Those must be built beforehand, breferably using the scripts "make_externals.*".
set(Boost_REALPATH ON)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_LIBS OFF)
find_package(Boost REQUIRED COMPONENTS system chrono date_time filesystem)
find_package(OpenGL REQUIRED)
# You have to provide the directory where the externals got installed to. The scripts make_*.sh and
# make_*.bat set this directory via the command line.
set(COSMOSCOUT_EXTERNALS_DIR COSMOSCOUT_EXTERNALS_DIR-NotFound
CACHE STRING "Directory where the externals got installed to.")
# Make sure to use forward slashes only.
file(TO_CMAKE_PATH ${COSMOSCOUT_EXTERNALS_DIR} COSMOSCOUT_EXTERNALS_DIR)
if (DEFINED ENV{CARES_ROOT_DIR})
SET(CARES_ROOT_DIR "$ENV{CARES_ROOT_DIR}")
else()
SET(CARES_ROOT_DIR ${COSMOSCOUT_EXTERNALS_DIR})
endif()
if (DEFINED ENV{CURL_ROOT_DIR})
SET(CURL_ROOT_DIR "$ENV{CURL_ROOT_DIR}")
else()
SET(CURL_ROOT_DIR ${COSMOSCOUT_EXTERNALS_DIR})
endif()
if (DEFINED ENV{CURLPP_ROOT_DIR})
SET(CURLPP_ROOT_DIR "$ENV{CURLPP_ROOT_DIR}")
else()
SET(CURLPP_ROOT_DIR ${COSMOSCOUT_EXTERNALS_DIR})
endif()
if (DEFINED ENV{SPDLOG_ROOT_DIR})
SET(SPDLOG_ROOT_DIR "$ENV{SPDLOG_ROOT_DIR}")
else()
SET(SPDLOG_ROOT_DIR ${COSMOSCOUT_EXTERNALS_DIR})
endif()
if (DEFINED ENV{GLM_ROOT_DIR})
SET(GLM_ROOT_DIR "$ENV{GLM_ROOT_DIR}")
else()
SET(GLM_ROOT_DIR ${COSMOSCOUT_EXTERNALS_DIR})
endif()
if (DEFINED ENV{GLI_ROOT_DIR})
SET(GLI_ROOT_DIR "$ENV{GLI_ROOT_DIR}")
else()
SET(GLI_ROOT_DIR ${COSMOSCOUT_EXTERNALS_DIR})
endif()
if (DEFINED ENV{DOCTEST_ROOT_DIR})
SET(DOCTEST_ROOT_DIR "$ENV{DOCTEST_ROOT_DIR}")
else()
SET(DOCTEST_ROOT_DIR ${COSMOSCOUT_EXTERNALS_DIR})
endif()
if (DEFINED ENV{TINYGLTF_ROOT_DIR})
SET(TINYGLTF_ROOT_DIR "$ENV{TINYGLTF_ROOT_DIR}")
else()
SET(TINYGLTF_ROOT_DIR ${COSMOSCOUT_EXTERNALS_DIR})
endif()
if (DEFINED ENV{CSPICE_ROOT_DIR})
SET(CSPICE_ROOT_DIR "$ENV{CSPICE_ROOT_DIR}")
else()
SET(CSPICE_ROOT_DIR ${COSMOSCOUT_EXTERNALS_DIR})
endif()
if (DEFINED ENV{CEF_ROOT_DIR})
SET(CEF_ROOT_DIR "$ENV{CEF_ROOT_DIR}")
else()
SET(CEF_ROOT_DIR ${COSMOSCOUT_EXTERNALS_DIR})
endif()
if (DEFINED ENV{TIFF_ROOT_DIR})
SET(TIFF_ROOT_DIR "$ENV{TIFF_ROOT_DIR}")
else()
SET(TIFF_ROOT_DIR ${COSMOSCOUT_EXTERNALS_DIR})
endif()
if (DEFINED ENV{GLEW_ROOT_DIR})
SET(GLEW_ROOT_DIR "$ENV{GLEW_ROOT_DIR}")
else()
SET(GLEW_ROOT_DIR ${COSMOSCOUT_EXTERNALS_DIR})
endif()
if (DEFINED ENV{SDL2_ROOT_DIR})
SET(SDL2_ROOT_DIR "$ENV{SDL2_ROOT_DIR}")
else()
SET(SDL2_ROOT_DIR ${COSMOSCOUT_EXTERNALS_DIR})
endif()
if (DEFINED ENV{SDL2_TTF_ROOT_DIR})
SET(SDL2_TTF_ROOT_DIR "$ENV{SDL2_TTF_ROOT_DIR}")
else()
SET(SDL2_TTF_ROOT_DIR ${COSMOSCOUT_EXTERNALS_DIR})
endif()
if (DEFINED ENV{OPENSG_ROOT_DIR})
SET(OPENSG_ROOT_DIR "$ENV{OPENSG_ROOT_DIR}")
else()
SET(OPENSG_ROOT_DIR ${COSMOSCOUT_EXTERNALS_DIR})
endif()
if (DEFINED ENV{CIVETWEB_ROOT_DIR})
SET(CIVETWEB_ROOT_DIR "$ENV{CIVETWEB_ROOT_DIR}")
else()
SET(CIVETWEB_ROOT_DIR ${COSMOSCOUT_EXTERNALS_DIR})
endif()
if (DEFINED ENV{VISTA_CMAKE_CONFIG_DIR})
SET(VistaCoreLibs_DIR "$ENV{VISTA_CMAKE_CONFIG_DIR}")
else()
SET(VistaCoreLibs_DIR ${COSMOSCOUT_EXTERNALS_DIR}/share/VistaCoreLibs/cmake)
endif()
find_package(GLM REQUIRED)
find_package(GLI REQUIRED)
find_package(DOCTEST REQUIRED)
find_package(TINYGLTF REQUIRED)
find_package(CSPICE REQUIRED)
find_package(CARES REQUIRED)
find_package(CURL REQUIRED)
find_package(CURLPP REQUIRED)
find_package(SPDLOG REQUIRED)
find_package(CEF REQUIRED)
find_package(TIFF REQUIRED)
find_package(GLEW REQUIRED)
find_package(SDL2 REQUIRED)
find_package(SDL2_ttf REQUIRED)
find_package(OPENSG REQUIRED)
find_package(CIVETWEB REQUIRED)
find_package(VistaCoreLibs REQUIRED
COMPONENTS "VistaBase" "VistaKernel" "VistaKernelOpenSGExt" "VistaOGLExt"
)
# X11 is used on Linux to set the application window's name and icon.
if (UNIX)
find_package(X11)
endif()
# install some files -------------------------------------------------------------------------------
# Copy all third-party libraries to install directory.
install(
DIRECTORY ${COSMOSCOUT_EXTERNALS_DIR}/lib/ ${COSMOSCOUT_EXTERNALS_DIR}/bin/
DESTINATION "lib"
FILES_MATCHING PATTERN "*.so*" PATTERN "*.dll*"
)
# Copy boost libraries to install directory.
foreach(BOOST_LIB
${Boost_CHRONO_LIBRARY_DEBUG}
${Boost_CHRONO_LIBRARY_RELEASE}
${Boost_DATE_TIME_LIBRARY_DEBUG}
${Boost_DATE_TIME_LIBRARY_RELEASE}
${Boost_FILESYSTEM_LIBRARY_RELEASE}
${Boost_FILESYSTEM_LIBRARY_DEBUG}
${Boost_SYSTEM_LIBRARY_RELEASE}
${Boost_SYSTEM_LIBRARY_DEBUG}
)
if(EXISTS "${BOOST_LIB}")
get_filename_component(LIB_BASE_NAME ${BOOST_LIB} NAME_WE)
get_filename_component(LIB_PATH ${BOOST_LIB} PATH)
if (WIN32)
install(FILES ${LIB_PATH}/${LIB_BASE_NAME}.dll DESTINATION "lib")
endif()
if (UNIX)
file(GLOB LIB_FILES ${LIB_PATH}/${LIB_BASE_NAME}.so*)
install(FILES ${LIB_FILES} DESTINATION "lib")
endif()
endif()
endforeach()
# Install documentation directory
install(DIRECTORY
${CMAKE_SOURCE_DIR}/docs
DESTINATION "."
)
# Install license files
install(FILES
${CMAKE_SOURCE_DIR}/LICENSE-3RD-PARTY.txt
${CMAKE_SOURCE_DIR}/LICENSE.md
DESTINATION "docs"
)
install(DIRECTORY
${CMAKE_SOURCE_DIR}/LICENSES
DESTINATION "docs"
)
# create version header ----------------------------------------------------------------------------
message(STATUS "Trying to get current git branch and commit...")
# Get the current git branch name.
execute_process(
COMMAND git rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# Get the current commit hash.
execute_process(
COMMAND git log -1 --format=%h
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# Fallback to project version if it failed.
if (GIT_BRANCH STREQUAL "")
message(STATUS " Failed - falling back to project version: v${PROJECT_VERSION}")
else()
message(STATUS " Success: v${PROJECT_VERSION} (${GIT_BRANCH} @${GIT_COMMIT_HASH})")
endif()
configure_file(
${CMAKE_SOURCE_DIR}/src/cs-core/cs-version.hpp.in
${CMAKE_BINARY_DIR}/src/cs-core/cs-version.hpp
)
# compiler settings --------------------------------------------------------------------------------
add_definitions(
-DBOOST_ALL_DYN_LINK
-DGLM_ENABLE_EXPERIMENTAL
-DGLM_FORCE_SWIZZLE
-DNOMINMAX
-DSPDLOG_COMPILED_LIB
)
if (MSVC)
add_definitions(
# For whatever reason ViSTA checks for 'WIN32' instead of '_WIN32' in a lot of places, which
# results in Linux code being included on Windows.
-DWIN32
)
add_compile_options(
$<$<COMPILE_LANGUAGE:CXX>:-experimental:external>
$<$<COMPILE_LANGUAGE:CXX>:-external:anglebrackets>
$<$<COMPILE_LANGUAGE:CXX>:-external:W0>
$<$<COMPILE_LANGUAGE:CXX>:-W3>
$<$<COMPILE_LANGUAGE:CXX>:-WX>
$<$<COMPILE_LANGUAGE:CXX>:-EHsc>
$<$<COMPILE_LANGUAGE:CXX>:-wd4251>
# Warns about multiple inheritance problems, which we can't avoid inheriting from ViSTA classes.
$<$<COMPILE_LANGUAGE:CXX>:-wd4250>
)
else()
add_compile_options(
$<$<COMPILE_LANGUAGE:CXX>:-Wall>
$<$<COMPILE_LANGUAGE:CXX>:-Werror>
)
endif()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Enable unit tests
option(COSMOSCOUT_UNIT_TESTS "Enable compilation of tests" OFF)
if (NOT COSMOSCOUT_UNIT_TESTS)
add_definitions(-DDOCTEST_CONFIG_DISABLE)
endif()
# Enable code coverage measurements
option(COSMOSCOUT_COVERAGE_INFO "Run code coverage analytics" OFF)
if(COSMOSCOUT_COVERAGE_INFO AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
add_definitions(--coverage)
add_link_options(--coverage)
endif()
# subdirectories -----------------------------------------------------------------------------------
include_directories(
${CMAKE_BINARY_DIR}/src/cs-core
${CMAKE_BINARY_DIR}/src/cs-utils
${CMAKE_BINARY_DIR}/src/cs-graphics
${CMAKE_BINARY_DIR}/src/cs-gui
${CMAKE_BINARY_DIR}/src/cs-scene
)
add_subdirectory(config)
add_subdirectory(resources)
add_subdirectory(src)
add_subdirectory(plugins)
add_subdirectory(tools/eclipse-shadow-generator)