-
Notifications
You must be signed in to change notification settings - Fork 31
/
CMakeLists.txt
439 lines (359 loc) · 14 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
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
################################################################
# Project GUACAMOLE
################################################################
PROJECT(GUACAMOLE CXX)
# neccessary for try_compile_scripts under linux
ENABLE_LANGUAGE(C)
# version number
set(GUACAMOLE_MAJOR 1)
set(GUACAMOLE_MINOR 8)
set(GUACAMOLE_PATCH 18)
set(GUACAMOLE_VERSION ${GUACAMOLE_MAJOR}.${GUACAMOLE_MINOR}.${GUACAMOLE_PATCH})
set(GUACAMOLE_DESCRIPTION "GUACAMOLE - an astonishing virtual reality engine")
set(GUACAMOLE_HOMEPAGE "http://www.GUACAMOLE.org")
set(GUACAMOLE_EXENAME "GUACAMOLE")
set(GUACAMOLE_PACKAGENAME "GUACAMOLE")
option (GUACAMOLE_ENABLE_PHYSICS "Set to enable physics support." OFF)
option (GUACAMOLE_ENABLE_VIRTUAL_TEXTURING "Set to enable virtual texturing support (requires lamure-vt)." OFF)
option (GUACAMOLE_GLFW3 "Set to enable glfw3 support." ON)
option (GUACAMOLE_ENABLE_PIPELINE_PASS_TIME_QUERIES "Set to enable profile using per-pass time queries." OFF)
option (GUACAMOLE_RUNTIME_PROGRAM_COMPILATION "Set to enable to runtime generation of ubershaders." ON)
option (GUACAMOLE_ENABLE_NVIDIA_3D_VISION "Set to enable NVIDIA 3D Vision active stereo." OFF)
option (GUACAMOLE_TESTS "Enable testing." OFF)
# fbx import crashes on nodetype-cast on windows
if (NOT WIN32)
option (GUACAMOLE_FBX "Set to enable FBX support." ON)
else ()
option (GUACAMOLE_FBX "Set to enable FBX support." OFF)
endif(NOT WIN32)
# We require at least version 3.0.2
cmake_minimum_required(VERSION 3.0.2)
if (UNIX)
find_package(PkgConfig)
endif(UNIX)
# Location where cmake first looks for modules.
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
SET(CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/install" CACHE PATH "Default install
prefix" FORCE)
ENDIF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
if(GUACAMOLE_ENABLE_NVIDIA_3D_VISION)
set(GUACAMOLE_NVIDIA_3D_VISION_FIRMWARE_PATH "${CMAKE_INSTALL_PREFIX}/lib_external/nvstusb.fw")
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/externals/nvstusb/ DESTINATION lib_external
FILES_MATCHING
PATTERN "*.fw"
)
if (UNIX)
pkg_check_modules(LIBUSB REQUIRED libusb-1.0)
endif (UNIX)
endif(GUACAMOLE_ENABLE_NVIDIA_3D_VISION)
###############################################################################
# write Config.h
###############################################################################
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/include/gua/config.hpp.in
${PROJECT_BINARY_DIR}/include/gua/config.hpp
)
install(FILES ${PROJECT_BINARY_DIR}/include/gua/config.hpp DESTINATION include/gua)
# add the binary tree to the search path for include files
# so that we will find the generated config.hpp
include_directories("${PROJECT_BINARY_DIR}/include")
################################################################
# Configure and find libraries
################################################################
set(GLOBAL_EXT_DIR ${GUACAMOLE_SOURCE_DIR}/externals)
if(MSVC)
option(CONTAINER_DEPLOYMENT_BUILD "Set to enable Docker-based deployment behaviors" ON)
endif()
if(CONTAINER_DEPLOYMENT_BUILD)
set(GLOBAL_EXT_DIR ${DEPLOYMENT_EXTERNALS})
endif(CONTAINER_DEPLOYMENT_BUILD)
include(define_macros)
include(find_compiler)
## assimp ######################################################
if (UNIX)
pkg_check_modules(ASSIMP REQUIRED assimp)
pkg_check_modules(GL REQUIRED gl)
pkg_check_modules(GLEW REQUIRED glew)
include(find_x11)
elseif (MSVC)
include(FindAssimp)
set(GL_LIBRARIES OpenGL32.lib)
endif (UNIX)
## assimp ######################################################
if (MSVC)
include(FindFreeImage)
endif ()
## schism ######################################################
include(FindSchism)
## boost ######################################################
if (UNIX)
set (BOOST_ROOT "/opt/boost/current" CACHE PATH "Set to your boost install")
elseif (WIN32)
set(BOOST_ROOT ${GLOBAL_EXT_DIR}/boost CACHE PATH "Set to your boost install")
#set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
add_definitions("-DBOOST_ALL_NO_LIB")
set(BOOST_INCLUDEDIR ${GLOBAL_EXT_DIR}/boost/include)
set(BOOST_LIBRARYDIR ${GLOBAL_EXT_DIR}/boost/lib)
endif (UNIX)
mark_as_advanced(Boost_DIR)
find_package( Boost 1.54.0 COMPONENTS
chrono
filesystem
program_options
regex
system
log
REQUIRED
)
## ZMQ ######################################################
include(FindZMQ)
## bullet ###################################################
if (GUACAMOLE_ENABLE_PHYSICS)
if (UNIX)
set (BULLET_ROOT "/opt/bullet/default" CACHE PATH "Set to your bullet install path.")
elseif (WIN32)
set (BULLET_ROOT "externals/bullet" CACHE PATH "Set to your bullet install path.")
endif (UNIX)
find_package(Bullet REQUIRED)
include(FindHACD)
if (UNIX)
if (BULLET_COLLISION_LIBRARY)
set(BULLET_COLLISION_LIBRARY_DEBUG ${BULLET_COLLISION_LIBRARY})
endif (BULLET_COLLISION_LIBRARY)
if (BULLET_HACD_LIBRARY)
set(BULLET_HACD_LIBRARY_DEBUG ${BULLET_HACD_LIBRARY})
endif (BULLET_HACD_LIBRARY)
if (BULLET_DYNAMICS_LIBRARY)
set(BULLET_DYNAMICS_LIBRARY_DEBUG ${BULLET_DYNAMICS_LIBRARY})
endif (BULLET_DYNAMICS_LIBRARY)
if (BULLET_MATH_LIBRARY)
set(BULLET_MATH_LIBRARY_DEBUG ${BULLET_MATH_LIBRARY})
endif (BULLET_MATH_LIBRARY)
if (BULLET_SOFTBODY_LIBRARY)
set(BULLET_SOFTBODY_LIBRARY_DEBUG ${BULLET_SOFTBODY_LIBRARY})
endif (BULLET_SOFTBODY_LIBRARY)
endif(UNIX)
endif (GUACAMOLE_ENABLE_PHYSICS)
## fbx ###################################################
if (GUACAMOLE_FBX)
include(FindFBX)
set (FBX_ROOT "externals/fbx" CACHE PATH "Set to your FBX SDK install path.")
# set (FBX_INCLUDE_DIRS "externals/fbx/include" CACHE PATH "Set to your FBX SDK install path.")
# if (UNIX)
# set (FBXSDK_ROOT "/opt/bullet/default" CACHE PATH "Set to your bullet install path.")
# elseif (WIN32)
# set (FBXSDK_ROOT "externals/" CACHE PATH "Set to your bullet install path.")
# endif (UNIX)
find_package(FBX REQUIRED)
endif (GUACAMOLE_FBX)
## glfw ###################################################
if (GUACAMOLE_GLFW3)
find_package(GLFW3 REQUIRED)
endif (GUACAMOLE_GLFW3)
## unittest ###############################################
if (GUACAMOLE_TESTS)
include(FindUnitTest++)
endif()
if(GUACAMOLE_ENABLE_VIRTUAL_TEXTURING)
find_package(LamureVT)
endif(GUACAMOLE_ENABLE_VIRTUAL_TEXTURING)
## json ###################################################
find_package(Json REQUIRED)
option (GUACAMOLE_ENABLE_TURBOJPEG "Set to enable usage of TurboJPEG for decompressing images." OFF)
IF (GUACAMOLE_ENABLE_TURBOJPEG)
find_package(TurboJPEG REQUIRED)
ENDIF (GUACAMOLE_ENABLE_TURBOJPEG)
## setup paths and libraries ##############################
set(LIB_PATHS
${CMAKE_CURRENT_SOURCE_DIR}/lib
${ASSIMP_LIBRARY_DIRS}
${JSON_LIBRARY_DIRS}
${GL_LIBRARY_DIRS}
${GLEW_LIBRARY_DIRS}
${Boost_LIBRARY_DIRS}
${Boost_LIBRARY_DIR_RELEASE}
${Boost_LIBRARY_DIR_DEBUG}
${BULLET_LIBRARY_DIRS}
${FREEIMAGE_LIBRARY_DIR}
${FBX_LIBRARY_DIRS}
${SCHISM_LIBRARY_DIRS}
${ZMQ_LIBRARY_DIRS}
${X11_LIBRARY_DIRS}
${LAMURE_VT_LIBRARY_DIRS}
)
LINK_DIRECTORIES(${LIB_PATHS})
set(INCLUDE_PATHS
${CMAKE_CURRENT_SOURCE_DIR}/build
${CMAKE_CURRENT_SOURCE_DIR}/externals
${CMAKE_CURRENT_SOURCE_DIR}/include
)
set(INCLUDE_PATHS_EXTERNAL
${SCHISM_INCLUDE_DIRS}
${Boost_INCLUDE_DIRS}
${ASSIMP_INCLUDE_DIR}
${JSON_INCLUDE_DIRS}
${GL_INCLUDE_DIRS}
${GLEW_INCLUDE_DIRS}
${BULLET_INCLUDE_DIRS}
${FREEIMAGE_INCLUDE_DIR}
${FBX_INCLUDE_DIRS}
${ZMQ_INCLUDE_DIRS}
${X11_INCLUDE_DIRS}
${LAMURE_VT_INCLUDE_DIRS}
)
if (GUACAMOLE_GLFW3)
LIST(APPEND INCLUDE_PATHS ${GLFW_INCLUDE_DIRS})
endif (GUACAMOLE_GLFW3)
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif()
if (UNIX)
set(CMAKE_CXX_FLAGS_RELEASE "-s -O4 --std=c++11 -fopenmp -Wall")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g -DNDEBUG --std=c++11 -fopenmp -Wall")
set(CMAKE_CXX_FLAGS_DEBUG "-g --std=c++11 -fopenmp -Wall")
elseif(MSVC)
set(CMAKE_CXX_FLAGS_RELEASE "-D NDEBUG -D WIN32_LEAN_AND_MEAN -D _USE_MATH_DEFINES -D NOMINMAX -D _SECURE_SCL=0 -D _SCL_SECURE_NO_WARNINGS -D _CRT_SECURE_NO_DEPRECATE /MD /MP")
set(CMAKE_CXX_FLAGS_DEBUG "-D_DEBUG -D WIN32_LEAN_AND_MEAN -D _USE_MATH_DEFINES -D NOMINMAX /MDd /Zi /MP")
endif(UNIX)
################################################################
# Create GuaRC
################################################################
if (NOT ${GUACAMOLE_RUNTIME_PROGRAM_COMPILATION})
add_subdirectory(guarc)
endif (NOT ${GUACAMOLE_RUNTIME_PROGRAM_COMPILATION})
################################################################
# Generate RC data
################################################################
IF (NOT ${GUACAMOLE_RUNTIME_PROGRAM_COMPILATION})
# list resource files
file(GLOB_RECURSE RESOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
resources/*
)
if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/include/gua/generated/)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/gua/generated)
endif()
if (NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/src/gua/generated/)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/gua/generated)
endif()
IF (UNIX)
ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/src/gua/generated/R.inl
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/guarc/guarc
${CMAKE_CURRENT_SOURCE_DIR}/resources
${CMAKE_CURRENT_SOURCE_DIR}/include/gua/generated/R.inl
${CMAKE_CURRENT_SOURCE_DIR}/src/gua/generated/R.inl
DEPENDS ${RESOURCES} guarc
)
ADD_CUSTOM_TARGET(CompileResources ALL
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src/gua/generated/R.inl
)
ELSEIF(MSVC)
ADD_CUSTOM_TARGET(CompileResources ALL
DEPENDS ${RESOURCES} guarc
)
SET (_GUARC_EXECUTABLE "")
SET (_GUARC_EXECUTABLE "/guarc/$(Configuration)/guarc.exe")
ADD_CUSTOM_COMMAND(TARGET CompileResources POST_BUILD
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}${_GUARC_EXECUTABLE}
${CMAKE_CURRENT_SOURCE_DIR}/resources
${CMAKE_CURRENT_SOURCE_DIR}/include/gua/generated/R.inl
${CMAKE_CURRENT_SOURCE_DIR}/src/gua/generated/R.inl
)
ENDIF(UNIX)
ENDIF (NOT ${GUACAMOLE_RUNTIME_PROGRAM_COMPILATION})
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
################################################################
# Build external sources
################################################################
add_subdirectory(externals)
################################################################
# Create libraries
################################################################
add_subdirectory(src)
################################################################
# Create plugins
################################################################
add_subdirectory(plugins)
################################################################
# Testing
################################################################
if (GUACAMOLE_TESTS)
add_subdirectory(tests)
enable_testing()
add_test( NAME testGUA COMMAND runTests )
endif (GUACAMOLE_TESTS)
################################################################
## gather MSVC runtime libraries
################################################################
FILE(GLOB_RECURSE _RUNTIME_LIBRARIES ${GLOBAL_EXT_DIR} ${GLOBAL_EXT_DIR}/*.dll)
SET(GUACAMOLE_RUNTIME_LIBRARIES ${_RUNTIME_LIBRARIES} CACHE INTERNAL "Runtime libraries.")
################################################################
# Examples
################################################################
option (GUACAMOLE_EXAMPLES "Build examples." ON)
if (GUACAMOLE_EXAMPLES)
add_subdirectory(examples)
endif (GUACAMOLE_EXAMPLES)
################################################################
# Summary
################################################################
message(STATUS "" )
message(STATUS "Summary:" )
message(STATUS " build type: ${CMAKE_BUILD_TYPE}" )
message(STATUS "" )
message(STATUS " schism:" )
message(STATUS " library: ${SCHISM_LIBRARIES}" )
message(STATUS " library path: ${SCHISM_LIBRARY_DIRS}" )
message(STATUS " include: ${SCHISM_INCLUDE_DIRS}" )
message(STATUS "" )
message(STATUS " boost:" )
message(STATUS " library: ${Boost_LIBRARIES}" )
message(STATUS " library path: ${Boost_LIBRARY_DIRS}" )
message(STATUS " include: ${Boost_INCLUDE_DIRS}" )
message(STATUS "" )
message(STATUS " assimp:" )
message(STATUS " library: ${ASSIMP_LIBRARIES}" )
message(STATUS " library path: ${ASSIMP_LIBRARY_DIRS}" )
message(STATUS " include: ${ASSIMP_INCLUDE_DIRS}" )
message(STATUS "" )
message(STATUS " json:" )
message(STATUS " library: ${JSON_LIBRARIES}" )
message(STATUS " library path: ${JSON_LIBRARY_DIRS}" )
message(STATUS " include: ${JSON_INCLUDE_DIRS}" )
message(STATUS "" )
message(STATUS " x11:" )
message(STATUS " library: ${X11_LIBRARIES}" )
message(STATUS " library path: ${X11_LIBRARY_DIRS}" )
message(STATUS " include: ${X11_INCLUDE_DIRS}" )
message(STATUS "" )
message(STATUS " gl:" )
message(STATUS " library: ${GL_LIBRARIES}" )
message(STATUS " include: ${GL_INCLUDE_DIRS}" )
message(STATUS "" )
message(STATUS " glew:" )
message(STATUS " library: ${GLEW_LIBRARIES}" )
message(STATUS " include: ${GLEW_INCLUDE_DIRS}" )
message(STATUS "" )
if (GUACAMOLE_ENABLE_PHYSICS)
message(STATUS " bullet:" )
message(STATUS " library: ${BULLET_LIBRARIES}" )
message(STATUS " library path: ${BULLET_LIBRARY_DIRS}" )
message(STATUS " include: ${BULLET_INCLUDE_DIRS}" )
message(STATUS "" )
endif (GUACAMOLE_ENABLE_PHYSICS)
if (GUACAMOLE_FBX)
message(STATUS " FBX SDK:" )
message(STATUS " library: ${FBX_LIBRARIES}" )
message(STATUS " library path: ${FBX_LIBRARY_DIRS}" )
message(STATUS " include: ${FBX_INCLUDE_DIRS}" )
message(STATUS "" )
endif (GUACAMOLE_FBX)
if (GUACAMOLE_GLFW3)
message(STATUS " glfw:" )
message(STATUS " library: ${GLFW_LIBRARIES}" )
message(STATUS " library path: ${GLFW_LIBRARY_DIRS}" )
message(STATUS " include: ${GLFW_INCLUDE_DIRS}" )
message(STATUS "" )
endif (GUACAMOLE_GLFW3)
message(STATUS "" )