-
Notifications
You must be signed in to change notification settings - Fork 7
/
CMakeLists.txt
362 lines (293 loc) · 11.5 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
PROJECT( tinia )
CMAKE_MINIMUM_REQUIRED( VERSION 2.6)
SET( version_number "0.3.0" )
SET(TINIA_VERSION ${version_number})
IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE Release CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
FORCE)
# Tagging debug-libraries
# Note: If the postfix string is changed, remember also to modify the contents of config/debug/mod_trell.load!
SET(CMAKE_DEBUG_POSTFIX "d")
ENDIF(NOT CMAKE_BUILD_TYPE)
# Set shared for linux:
IF(NOT WIN32)
IF(NOT DEFINED ${BUILD_SHARED_LIBS})
SET(BUILD_SHARED_LIBS ON)
ENDIF()
ENDIF()
if(WIN32 AND NOT CYGWIN)
set(DEF_INSTALL_CMAKE_DIR cmake)
else()
set(DEF_INSTALL_CMAKE_DIR lib/cmake/Tinia)
endif()
set(INSTALL_CMAKE_DIR ${DEF_INSTALL_CMAKE_DIR} CACHE PATH
"Installation directory for CMake files")
IF(NOT WIN32)
OPTION( Tinia_SERVER "Build mod_tinia_trell and related components?" ON)
ELSE()
OPTION( Tinia_SERVER "Build mod_tinia_trell and related components?" OFF)
ENDIF()
OPTION( Tinia_DESKTOP "Build qtcontroller?" ON )
OPTION( Tinia_BUILD_EXAMPLES "Build example jobs?" ON )
OPTION( Tinia_BUILD_TUTORIALS "Build tutorials?" ON )
OPTION( Tinia_BUILD_UNIT_TESTS "Build unit tests?" ON )
OPTION( Tinia_AMAZON "Configurations needed to make Tinia work smoothly on Amazon" OFF)
OPTION( Tinia_IPC_LOG_TRACE "Enable numerous logging messages to track actions of IPC threads" OFF )
OPTION( Tinia_IPC_VALGRIND_ANNOTATIONS "Enable some annotation for valgrind and its tools" OFF )
OPTION( Tinia_EXTEND_CMAKE_MODULE_PATH
"Extend the CMAKE_MODULE_PATH variable with user directories?"
ON )
MARK_AS_ADVANCED( Tinia_EXTEND_CMAKE_MODULE_PATH )
IF( Tinia_EXTEND_CMAKE_MODULE_PATH )
SET( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
${CMAKE_SOURCE_DIR}/cmake/Modules )
ENDIF()
IF(WIN32)
ADD_DEFINITIONS( -DBOOST_ALL_NO_LIB )
ADD_DEFINITIONS( -D_SCL_SECURE_NO_WARNINGS )
ADD_DEFINITIONS( -D_CRT_SECURE_NO_WARNINGS )
SET( CMAKE_INSTALL_PREFIX "$ENV{PROGRAMFILES(x86)}/SINTEF/tinia" CACHE PATH "Path to install tinia")
SET( Tinia_3RDPARTY_LOC $ENV{TINIA_3RDPARTY} CACHE PATH "Location of Tinia 3rdparty" )
SET(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH}
"${Tinia_3RDPARTY_LOC}" )
ENDIF()
IF(Tinia_AMAZON)
ADD_DEFINITIONS(-DTINIA_AMAZON)
ENDIF()
IF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC)
SET(CMAKE_CXX_FLAGS "-Wall -fPIC -std=c++0x ${CMAKE_CXX_FLAGS}" )
IF( Tinia_IPC_LOG_TRACE )
add_definitions( -DTINIA_IPC_LOG_TRACE )
ENDIF( Tinia_IPC_LOG_TRACE )
ENDIF()
IF(MSVC10)
#Enable multiprocessor compilation for speed
#SET(CMAKE_CXX_FLAGS " /MP ${CMAKE_CXX_FLAGS}" CACHE STRING " " FORCE)
#CAREFUL, this will append the above string for each time CMAKE is run!
ENDIF()
# We don't need XML support on Windows (only needed for mod_tinia_trell...)
IF(Tinia_SERVER)
find_package( LibXml2 REQUIRED )
ELSE()
find_package(LibXml2)
ENDIF()
IF(LIBXML2_FOUND)
SET(TINIA_LIBRARIES_FOR_CONFIG ${TINIA_LIBRARIES_FOR_CONFIG} ${LIBXML2_LIBRARIES})
ADD_DEFINITIONS(-DTINIA_HAVE_LIBXML)
ELSE()
SET(LIBXML2_INCLUDE_DIRS "")
SET(LIBXML2_INCLUDE_DIR "")
SET(LIBXML2_LIBRARIES "")
ENDIF()
##### BOOST #####
set(BOOST_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
FIND_PACKAGE( Boost REQUIRED COMPONENTS unit_test_framework prg_exec_monitor thread date_time system )
SET(TINIA_LIBRARIES_FOR_CONFIG ${TINIA_LIBRARIES_FOR_CONFIG} ${Boost_LIBRARIES})
##### QT #####
IF(Tinia_DESKTOP)
FIND_PACKAGE(Qt4 COMPONENTS QtCore QtGui QtOpenGL QtXML QtScript QtNetwork REQUIRED)
INCLUDE(${QT_USE_FILE})
SET(QT_USE_QTOPENGL TRUE)
SET(QT_USE_QTXML TRUE)
SET(QT_USE_QTNETWORK TRUE)
SET(QT_USE_QTSCRIPT TRUE)
QT4_WRAP_CPP(qtcontroller_HEADERS_MOC ${qtcontroller_SOURCES_TO_BE_MOCED} ${qtcontroller_SOURCES})
QT4_WRAP_UI(qtcontroller_FORMS_HEADERS ${qtcontroller_FORMS})
ADD_DEFINITIONS(${QT_DEFINITIONS})
ADD_DEFINITIONS(-DQT_SHARED)
SET(TINIA_LIBRARIES_FOR_CONFIG ${TINIA_LIBRARIES_FOR_CONFIG} ${LIBXML2_LIBRARIES} ${QT_LIBRARIES})
ENDIF()
##### OPENGL #####
FIND_PACKAGE( OpenGL REQUIRED )
FIND_PACKAGE( GLEW REQUIRED )
FIND_PACKAGE( GLM REQUIRED )
SET(TINIA_LIBRARIES_FOR_CONFIG ${TINIA_LIBRARIES_FOR_CONFIG} ${OPENGL_LIBRARIES} ${GLEW_LIBRARIES})
IF(Tinia_SERVER)
IF( Tinia_IPC_VALGRIND_ANNOTATIONS )
FIND_PATH(
VALGRIND_INCLUDE_DIR valgrind.h
HINTS "/usr/include/valgrind"
)
ADD_DEFINITIONS( -DTINIA_IPC_VALGRIND_ANNOTATIONS )
ENDIF( Tinia_IPC_VALGRIND_ANNOTATIONS )
FIND_PATH( APACHE_INCLUDE_DIR httpd.h
HINTS "/usr/include/apache2" "/usr/include/httpd/"
)
FIND_LIBRARY( RT
NAMES rt
PATHS "/usr/lib/x86_64-linux-gnu/" "/usr/lib/"
)
FIND_LIBRARY(LIB_APR
NAMES apr-1
PATHS "/usr/lib/"
)
FIND_LIBRARY(LIB_TURBOJPEG
NAMES turbojpeg
HINTS "/usr/lib/" "/opt/libjpeg-turbo/lib64/"
)
FIND_PATH(TURBOJPEG_INCLUDE_DIR "turbojpeg.h"
HINTS "/opt/" "/opt/libjpeg-turbo/" "/opt/libjpeg-turbo/include/"
"/usr/include/" "/usr/local/include/"
)
FIND_PACKAGE( Threads )
FIND_PATH(APR_INCLUDE_DIR "apr.h"
HINTS "/usr/include/apr-1.0"
"/usr/include/apr-1"
"apr-1/"
"apr-1.0"
)
SET(TINIA_LIBRARIES_FOR_CONFIG ${TINIA_LIBRARIES_FOR_CONFIG} ${RT} ${CMAKE_THREAD_LIBS_INIT} ${LIB_APR} ${LIB_TURBOJPEG})
ENDIF()
SET(TINIA_EXTERNAL_INCLUDE_DIRS
${LIBXML2_INCLUDE_DIR}
${GLEW_INCLUDE_DIR}
${GLM_INCLUDE_DIR}
${APACHE_INCLUDE_DIR}
${VALGRIND_INCLUDE_DIR}
${APR_INCLUDE_DIR}
${TURBOJPEG_INCLUDE_DIR}
${QT_INCLUDE_DIR}
${QT_QTOPENGL_INCLUDE_DIR}
${Boost_INCLUDE_DIRS})
include_directories( "./include"
${TINIA_EXTERNAL_INCLUDE_DIRS}
)
link_directories(
${Boost_LIBRARY_DIRS}
)
ADD_SUBDIRECTORY( "src/model" )
SET(TINIA_LIBRARIES_FOR_CONFIG ${TINIA_LIBRARIES_FOR_CONFIG} tinia_model)
IF(LIBXML2_FOUND)
ADD_SUBDIRECTORY( "src/modelxml" )
SET(TINIA_LIBRARIES_FOR_CONFIG ${TINIA_LIBRARIES_FOR_CONFIG} tinia_modelxml)
ENDIF()
ADD_SUBDIRECTORY( "src/renderlist" )
SET(TINIA_LIBRARIES_FOR_CONFIG ${TINIA_LIBRARIES_FOR_CONFIG} tinia_renderlist)
ADD_SUBDIRECTORY( "src/renderlistgl" )
SET(TINIA_LIBRARIES_FOR_CONFIG ${TINIA_LIBRARIES_FOR_CONFIG} tinia_renderlistgl)
ADD_SUBDIRECTORY( "src/jobcontroller" )
SET(TINIA_LIBRARIES_FOR_CONFIG ${TINIA_LIBRARIES_FOR_CONFIG} tinia_jobcontroller)
IF(Tinia_DESKTOP)
ADD_SUBDIRECTORY( "js")
SET(TINIA_LIBRARIES_FOR_CONFIG ${TINIA_LIBRARIES_FOR_CONFIG} tinia_javascript)
ADD_SUBDIRECTORY( "src/qtcontroller" )
SET(TINIA_LIBRARIES_FOR_CONFIG ${TINIA_LIBRARIES_FOR_CONFIG} tinia_qtcontroller)
ENDIF()
IF(Tinia_SERVER)
ADD_SUBDIRECTORY( "src/ipc" )
ADD_SUBDIRECTORY( "src/trell" )
SET(TINIA_LIBRARIES_FOR_CONFIG ${TINIA_LIBRARIES_FOR_CONFIG} tinia_trell)
ADD_SUBDIRECTORY( "src/mod_trell" )
ADD_SUBDIRECTORY( "src/trell_master" )
ENDIF()
ADD_SUBDIRECTORY( "src/utils" )
SET(TINIA_LIBRARIES_FOR_CONFIG ${TINIA_LIBRARIES_FOR_CONFIG} tinia_utils)
# --- The rest are built as applications using tinia ---------------------------
SET( TINIA_LIBRARIES ${TINIA_LIBRARIES_FOR_CONFIG} )
# Unit tests
IF( Tinia_BUILD_UNIT_TESTS )
IF( Tinia_SERVER )
ADD_SUBDIRECTORY( "unittests/ipc/" )
ENDIF( Tinia_SERVER )
ADD_SUBDIRECTORY( "unittests/model/" )
IF(LIBXML2_FOUND)
ADD_SUBDIRECTORY( "unittests/modelxml/" )
ENDIF()
ADD_SUBDIRECTORY( "unittests/renderlist/" )
ADD_SUBDIRECTORY( "unittests/jobcontroller/" )
IF(Tinia_DESKTOP)
ADD_SUBDIRECTORY( "unittests/qtcontroller/" )
IF(LIBXML2_FOUND)
# This has of course all dependencies of "sub-tests" combined.
ADD_SUBDIRECTORY( "unittests/combined/" )
ENDIF()
ENDIF()
ENDIF()
# Examples
IF( Tinia_BUILD_EXAMPLES )
ADD_SUBDIRECTORY( "examples/rlview/" )
ADD_SUBDIRECTORY( "examples/simplejob" )
IF(Tinia_DESKTOP)
ADD_SUBDIRECTORY( "examples/fpsviewer" )
ENDIF()
ADD_SUBDIRECTORY( "examples/cuberenderer")
ADD_SUBDIRECTORY( "examples/auto_proxy_test")
ADD_SUBDIRECTORY( "examples/jpg_proxy_test")
ADD_SUBDIRECTORY( "examples/changerestrictions")
ADD_SUBDIRECTORY( "examples/clock_example")
ADD_SUBDIRECTORY( "examples/twocanvases")
ENDIF()
#Tutorials
IF( Tinia_BUILD_TUTORIALS )
ADD_SUBDIRECTORY( "tutorials/tutorial1/")
ADD_SUBDIRECTORY( "tutorials/tutorial2/")
ADD_SUBDIRECTORY( "tutorials/tutorial3/")
ADD_SUBDIRECTORY( "tutorials/tutorial4/")
IF(Tinia_DESKTOP)
ADD_SUBDIRECTORY( "tutorials/tutorial5/")
ENDIF()
ENDIF()
FILE(GLOB tinia_headerFiles "include/tinia/*.hpp")
install( FILES
${tinia_headerFiles}
DESTINATION include/tinia/
COMPONENT tinia_dev)
#SET( CPACK_DEB_COMPONENT_INSTALL ON)
SET(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_SOURCE_DIR}/agpl-3.0.txt)
SET(CPACK_PACKAGE_VENDOR "SINTEF ICT")
SET(CPACK_PACKAGE_VERSION ${version_number} )
SET(TINIA_TARGETS_APPEND "")
# This is for local build directory:
IF(Tinia_DESKTOP)
IF(Tinia_SERVER)
export(TARGETS tinia_model tinia_jobcontroller tinia_modelxml tinia_qtcontroller tinia_renderlist tinia_renderlistgl tinia_javascript tiniaipc tinia_trell tinia_utils
FILE "${PROJECT_BINARY_DIR}/TiniaTargets${TINIA_TARGETS_APPEND}.cmake")
ELSE()
IF(LIBXML2_FOUND)
export(TARGETS tinia_model tinia_jobcontroller tinia_modelxml tinia_qtcontroller tinia_renderlist tinia_renderlistgl tinia_javascript tinia_utils
FILE "${PROJECT_BINARY_DIR}/TiniaTargets${TINIA_TARGETS_APPEND}.cmake")
ELSE()
export(TARGETS tinia_model tinia_jobcontroller tinia_qtcontroller tinia_renderlist tinia_renderlistgl tinia_javascript tinia_utils
FILE "${PROJECT_BINARY_DIR}/TiniaTargets${TINIA_TARGETS_APPEND}.cmake")
ENDIF()
ENDIF()
ELSE()
export(TARGETS tinia_model tinia_jobcontroller tinia_modelxml tinia_renderlist tinia_renderlistgl tiniaipc tinia_trell tinia_utils
FILE "${PROJECT_BINARY_DIR}/TiniaTargets${TINIA_TARGETS_APPEND}.cmake")
ENDIF()
set(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include" ${TINIA_EXTERNAL_INCLUDE_DIRS})
set(CONF_APPS_DIR "${PROJECT_BINARY_DIR}")
configure_file(TiniaConfig.cmake.in
"${PROJECT_BINARY_DIR}/TiniaConfig.cmake" @ONLY)
# This is for the installed file
# First we need relative path for include
file(RELATIVE_PATH REL_INCLUDE_DIR "${CMAKE_INSTALL_PREFIX}/${INSTALL_CMAKE_DIR}"
"${CMAKE_INSTALL_PREFIX}/include")
set(CONF_INCLUDE_DIRS "\${TINIA_CMAKE_DIR}/${REL_INCLUDE_DIR}" ${TINIA_EXTERNAL_INCLUDE_DIRS})
# And the relative path for apps:
file(RELATIVE_PATH REL_APPS_DIR "${CMAKE_INSTALL_PREFIX}/${INSTALL_CMAKE_DIR}"
"${CMAKE_INSTALL_PREFIX}/var/trell/apps")
set(CONF_APPS_DIR "\${TINIA_CMAKE_DIR}/${REL_APPS_DIR}")
configure_file(TiniaConfig.cmake.in
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TiniaConfig.cmake" @ONLY)
configure_file(TiniaConfigVersion.cmake.in
"${PROJECT_BINARY_DIR}/TiniaConfigVersion.cmake" @ONLY)
# We need to install the config files
install(FILES
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TiniaConfig.cmake"
"${PROJECT_BINARY_DIR}/TiniaConfigVersion.cmake"
DESTINATION "${INSTALL_CMAKE_DIR}" COMPONENT tinia_dev)
# Install the export set for use with the install-tree
install(EXPORT TiniaTargets DESTINATION
"${INSTALL_CMAKE_DIR}/" COMPONENT tinia_dev)
IF(NOT WIN32)
SET( CPACK_GENERATOR "DEB" )
SET( CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_SOURCE_DIR}/debian/postinst;${CMAKE_CURRENT_SOURCE_DIR}/debian/postrm;" )
SET( CPACK_DEBIAN_PACKAGE_MAINTAINER "[email protected]" )
SET(CPACK_MONOLITHIC_INSTALL 1)
SET( CPACK_PACKAGE_INSTALL_DIRECTORY "/" )
include ( CPack )
ENDIF()