-
Notifications
You must be signed in to change notification settings - Fork 15
/
CMakeLists.txt
423 lines (347 loc) · 14.2 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
##-*****************************************************************************
## Copyright 2015 Christopher Jon Horvath
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
## You may obtain a copy of the License at
##
## http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.
##-*****************************************************************************
# This is the top level of the EncinoWaves project. Bins and then libs!
# Also, this top level should include any "global" build configurations
CMAKE_MINIMUM_REQUIRED( VERSION 3.0 )
cmake_policy(SET CMP0048 NEW)
# Declare an EncinoWaves Project
PROJECT( EWAV VERSION 1.0.0 )
IF (NOT DEFINED QUIET)
SET(CMAKE_VERBOSE_MAKEFILE TRUE)
ENDIF()
#-******************************************************************************
# RPATH STUFF
#-******************************************************************************
# use, i.e. don't skip the full RPATH for the build tree
SET(CMAKE_SKIP_BUILD_RPATH FALSE)
# when building, don't use the install RPATH already
# (but later on when installing)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
# add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# the RPATH to be used when installing, but only if it's not a system directory
LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
IF("${isSystemDir}" STREQUAL "-1")
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
ENDIF("${isSystemDir}" STREQUAL "-1")
#-******************************************************************************
#-******************************************************************************
# EMLD
#-******************************************************************************
#-******************************************************************************
# Declare the version
#SET( PROJECT_VERSION_MAJOR 1 )
#SET( PROJECT_VERSION_MINOR 0 )
#SET( PROJECT_VERSION_PATCH 0 )
#SET( PROJECT_VERSION
# ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH} )
#SET( VERSION ${PROJECT_VERSION} )
MESSAGE(STATUS "CMAKE SYSTEM NAME = ${CMAKE_SYSTEM_NAME}" )
# Set some debug vs opt flags
IF ( "${CMAKE_BUILD_TYPE}" MATCHES "DebugHard" )
ADD_DEFINITIONS( -DDEBUG=1 -DDEBUG_HARD=1 -UNDEBUG -O0 -g )
ELSEIF ( "${CMAKE_BUILD_TYPE}" MATCHES "Debug" )
ADD_DEFINITIONS( -DDEBUG=1 -UDEBUG_HARD -UNDEBUG -O0 -g )
ELSEIF ( "${CMAKE_BUILD_TYPE}" MATCHES "Release" )
#ADD_DEFINITIONS( -DNDEBUG=1 -UDEBUG_HARD -UDEBUG -O3 -g )
ADD_DEFINITIONS( -DNDEBUG=1 -UDEBUG_HARD -UDEBUG -O3 )
ENDIF()
# FAST MATH
ADD_DEFINITIONS( -ffast-math )
# Windows flag
SET( WINDOWS FALSE )
IF( "${CMAKE_SYSTEM_NAME}" MATCHES "Windows" )
MESSAGE( FATAL_ERROR "Windows not supported." )
ENDIF()
# Darwin flag
SET( DARWIN FALSE )
IF( "${CMAKE_SYSTEM_NAME}" MATCHES "Darwin" )
SET( DARWIN TRUE )
ENDIF()
# Linux flag
SET( LINUX FALSE )
IF( "${CMAKE_SYSTEM_NAME}" MATCHES "Linux" )
SET( LINUX TRUE )
ENDIF()
#-******************************************************************************
# SPECIFY C++ 14 - BECAUSE IT IS AWESOME
#-******************************************************************************
IF( ${DARWIN} )
#ADD_DEFINITIONS( "-std=c++14" )
ADD_DEFINITIONS( "-std=c++14 -Wno-parentheses" )
ELSE()
#ADD_DEFINITIONS( "-std=c++0x" )
ENDIF()
#-******************************************************************************
# SPECIFY PLATFORM DEFINES
#-******************************************************************************
IF( ${DARWIN} )
ADD_DEFINITIONS( -DPLATFORM_DARWIN -DPLATFORM=DARWIN )
ELSE()
ADD_DEFINITIONS( -DPLATFORM_LINUX -DPLATFORM=LINUX )
ENDIF()
#-******************************************************************************
# CMAKE MODULE STUFF
#-******************************************************************************
# check in the source directory
set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/build )
#-******************************************************************************
# TESTING STUFF
#-******************************************************************************
# Globally enable testing.
INCLUDE(CTest)
ENABLE_TESTING()
IF(BUILD_TESTING)
SET(BUILDNAME "${BUILDNAME}" CACHE STRING "Name of build on the dashboard")
MARK_AS_ADVANCED(BUILDNAME)
ENDIF(BUILD_TESTING)
MESSAGE( STATUS "Enabled Testing" )
#-******************************************************************************
# FPIC STUFF
#-******************************************************************************
ADD_DEFINITIONS( -fPIC )
#-******************************************************************************
# WARNINGS MANAGEMENT
#-******************************************************************************
# Imath and Boost make fairly heavy use of the register keyword, which makes
# for quite a bit of warnings.
ADD_DEFINITIONS( "-Wno-deprecated-register" )
#-******************************************************************************
# THREAD BUILDING BLOCKS
# We handle these separately from the 'needs', because it's hard to
# use more than one of them on a system at any given time.
#-******************************************************************************
SET( TBB_ROOT $ENV{TBB_ROOT} )
SET( TBB_INCLUDE_PATH "${TBB_ROOT}/include" )
SET( TBB_LINK_PATH "${TBB_ROOT}/lib" )
FIND_LIBRARY( EWAV_TBB_LIB tbb
PATHS
${TBB_LINK_PATH}
NO_DEFAULT_PATH
NO_CMAKE_ENVIRONMENT_PATH
NO_SYSTEM_ENVIRONMENT_PATH
NO_CMAKE_SYSTEM_PATH )
FIND_LIBRARY( EWAV_TBBMALLOC_LIB tbbmalloc
PATHS
${TBB_LINK_PATH}
NO_DEFAULT_PATH
NO_CMAKE_ENVIRONMENT_PATH
NO_SYSTEM_ENVIRONMENT_PATH
NO_CMAKE_SYSTEM_PATH )
FIND_LIBRARY( EWAV_TBB_DEBUG_LIB tbb_debug
PATHS
${TBB_LINK_PATH}
NO_DEFAULT_PATH
NO_CMAKE_ENVIRONMENT_PATH
NO_SYSTEM_ENVIRONMENT_PATH
NO_CMAKE_SYSTEM_PATH )
FIND_LIBRARY( EWAV_TBBMALLOC_DEBUG_LIB tbbmalloc_debug
PATHS
${TBB_LINK_PATH}
NO_DEFAULT_PATH
NO_CMAKE_ENVIRONMENT_PATH
NO_SYSTEM_ENVIRONMENT_PATH
NO_CMAKE_SYSTEM_PATH )
SET( EWAV_TBB_OPT_LIBS
${EWAV_TBBMALLOC_LIB}
${EWAV_TBB_LIB} )
SET( EWAV_TBB_DEBUG_LIBS
${EWAV_TBBMALLOC_DEBUG_LIB}
${EWAV_TBB_DEBUG_LIB} )
IF ( "${CMAKE_BUILD_TYPE}" MATCHES "Debug" )
SET( EWAV_TBB_LIBS ${EWAV_TBB_DEBUG_LIBS} )
ELSE()
SET( EWAV_TBB_LIBS ${EWAV_TBB_OPT_LIBS} )
ENDIF()
MESSAGE( STATUS "TBB libs: ${EWAV_TBB_LIBS}" )
INCLUDE_DIRECTORIES( ${TBB_INCLUDE_PATH} )
#-******************************************************************************
#-******************************************************************************
# We handle our dependent libraries by having a 'needs' installation where
# everything is installed together. This makes it possible (at all) to
# have the libraries all cross compiled, and to have a single include
# path and link path. It takes quite some time to set up, but is worth it.
#-******************************************************************************
#-******************************************************************************
SET( EWAVNEEDS_ROOT $ENV{EWAVNEEDS_ROOT} )
SET( ZLIB_ROOT ${EWAVNEEDS_ROOT} )
SET( TIFF_ROOT ${EWAVNEEDS_ROOT} )
SET( JPEG_ROOT ${EWAVNEEDS_ROOT} )
SET( BOOST_ROOT ${EWAVNEEDS_ROOT} )
SET( ILMBASE_ROOT ${EWAVNEEDS_ROOT} )
SET( OPENEXR_ROOT ${EWAVNEEDS_ROOT} )
SET( GLFW_ROOT ${EWAVNEEDS_ROOT} )
SET( GLEW_ROOT ${EWAVNEEDS_ROOT} )
SET( HDF5_ROOT ${EWAVNEEDS_ROOT} )
SET( ALEMBIC_ROOT ${EWAVNEEDS_ROOT} )
SET( FFTW_ROOT ${EWAVNEEDS_ROOT} )
INCLUDE_DIRECTORIES( ${EWAVNEEDS_ROOT}/include )
INCLUDE_DIRECTORIES( ${EWAVNEEDS_ROOT}/include/OpenEXR )
#-******************************************************************************
#-******************************************************************************
# Z LIB
#-******************************************************************************
#-******************************************************************************
IF( ${DARWIN} )
FIND_PACKAGE( ZLIB REQUIRED )
SET( EWAV_Z_LIBS ${ZLIB_LIBRARIES} )
ELSE()
SET( EWAV_Z_LIBS ${EWAVNEEDS_ROOT}/lib/libz.a )
ENDIF()
#-******************************************************************************
#-******************************************************************************
# THREADS
#-******************************************************************************
#-******************************************************************************
IF( ${DARWIN} )
FIND_PACKAGE( Threads REQUIRED )
SET( EWAV_THREAD_LIBS ${CMAKE_THREAD_LIBS_INIT} )
ELSE()
SET( EWAV_THREAD_LIBS pthread )
ENDIF()
#-******************************************************************************
#-******************************************************************************
# X11 and Xrandr stuff (not sure if needed on darwin)
#-******************************************************************************
#-******************************************************************************
IF( ${DARWIN} )
ELSE()
#-******************************************************************************
# THIS IS A VERY INELEGANT WAY TO BUNDLE GLFW REQUIREMENTS.
# I COULDN'T FIND A SEXY FindGLFW.cmake on the net.
#-******************************************************************************
FIND_PACKAGE( Xrandr REQUIRED )
FIND_PACKAGE( X11 REQUIRED )
FIND_LIBRARY( rt_LIBRARIES rt )
FIND_LIBRARY( Xi_LIBRARIES Xi )
FIND_LIBRARY( Xxf86vm_LIBRARIES Xxf86vm )
FIND_LIBRARY( Xrender_LIBRARIES Xrender )
FIND_LIBRARY( Xext_LIBRARIES Xext )
FIND_LIBRARY( xcb_LIBRARIES xcb )
FIND_LIBRARY( Xau_LIBRARIES Xau )
SET( EWAV_XMISC_LIBS
${rt_LIBRARIES}
${Xrandr_LIBRARIES}
${Xi_LIBRARIES}
${Xxf86vm_LIBRARIES}
${Xrender_LIBRARIES}
${Xext_LIBRARIES}
${X11_LIBRARIES}
${xcb_LIBRARIES}
${Xau_LIBRARIES} )
ENDIF()
#-******************************************************************************
# OPEN GL STUFF
#-******************************************************************************
FIND_PACKAGE( OpenGL REQUIRED )
#FIND_PACKAGE( GLUT REQUIRED )
IF( ${DARWIN} )
SET( EWAV_GLFW_LIBS
${EWAVNEEDS_ROOT}/lib/libglfw3.a
${OPENGL_LIBRARIES} )
ELSE()
SET( EWAV_GLFW_LIBS
${EWAVNEEDS_ROOT}/lib/libglfw3.a
${EWAVNEEDS_ROOT}/lib/libGLEW.a
${OPENGL_LIBRARIES} )
ENDIF()
IF( ${DARWIN} )
# Do a darwin OpenGL thing.
SET( EWAV_GL_LIBS
${EWAV_GLFW_LIBS}
"-framework OpenGL"
"-framework IOKit"
"-framework Cocoa"
"-framework Carbon"
"-framework Foundation"
"-framework CoreVideo"
"-framework QuartzCore" )
ELSE()
SET( EWAV_GL_LIBS
${EWAV_GLFW_LIBS}
${EWAVNEEDS_ROOT}/lib/libGLEW.a
${EWAV_XMISC_LIBS}
${OPENGL_LIBRARIES} )
ENDIF()
#-******************************************************************************
# BOOST STUFF
#-******************************************************************************
#SET( EWAV_BOOST_LIBS
# ${EWAVNEEDS_ROOT}/lib/libboost_chrono.a
# ${EWAVNEEDS_ROOT}/lib/libboost_python.a
# ${EWAVNEEDS_ROOT}/lib/libboost_random.a
# ${EWAVNEEDS_ROOT}/lib/libboost_regex.a
# ${EWAVNEEDS_ROOT}/lib/libboost_program_options.a
# ${EWAVNEEDS_ROOT}/lib/libboost_thread.a
# ${EWAVNEEDS_ROOT}/lib/libboost_system.a )
SET( EWAV_BOOST_LIBS
${EWAVNEEDS_ROOT}/lib/libboost_chrono.a
${EWAVNEEDS_ROOT}/lib/libboost_random.a
${EWAVNEEDS_ROOT}/lib/libboost_regex.a
${EWAVNEEDS_ROOT}/lib/libboost_program_options.a
${EWAVNEEDS_ROOT}/lib/libboost_thread.a
${EWAVNEEDS_ROOT}/lib/libboost_system.a )
#-******************************************************************************
# ILM BASE
#-******************************************************************************
SET( EWAV_ILMBASE_LIBS
${EWAVNEEDS_ROOT}/lib/libImath.a
${EWAVNEEDS_ROOT}/lib/libIlmThread.a
${EWAVNEEDS_ROOT}/lib/libIex.a
${EWAVNEEDS_ROOT}/lib/libHalf.a )
#-******************************************************************************
# OPEN EXR
#-******************************************************************************
SET( EWAV_OPENEXR_LIBS
${EWAVNEEDS_ROOT}/lib/libIlmImf.a
${EWAVNEEDS_ROOT}/lib/libtiff.a
${EWAVNEEDS_ROOT}/lib/libjpeg.a )
#-******************************************************************************
# HDF5
#-******************************************************************************
SET( EWAV_HDF5_LIBS
${EWAVNEEDS_ROOT}/lib/libhdf5_hl.a
${EWAVNEEDS_ROOT}/lib/libhdf5.a )
#-******************************************************************************
# ALEMBIC
#-******************************************************************************
SET( EWAV_ALEMBIC_LIBS
${EWAVNEEDS_ROOT}/lib/libAlembicAbcOpenGL.a
${EWAVNEEDS_ROOT}/lib/libAlembicAbcCollection.a
${EWAVNEEDS_ROOT}/lib/libAlembicAbcMaterial.a
${EWAVNEEDS_ROOT}/lib/libAlembicAbcGeom.a
${EWAVNEEDS_ROOT}/lib/libAlembicAbc.a
${EWAVNEEDS_ROOT}/lib/libAlembicAbcCoreFactory.a
${EWAVNEEDS_ROOT}/lib/libAlembicAbcCoreOgawa.a
${EWAVNEEDS_ROOT}/lib/libAlembicAbcCoreHDF5.a
${EWAVNEEDS_ROOT}/lib/libAlembicAbcCoreAbstract.a
${EWAVNEEDS_ROOT}/lib/libAlembicOgawa.a
${EWAVNEEDS_ROOT}/lib/libAlembicUtil.a )
##-*****************************************************************************
# FFTW
##-*****************************************************************************
SET( EWAV_FFTW_LIBS
${EWAVNEEDS_ROOT}/lib/libfftw3_threads.a
${EWAVNEEDS_ROOT}/lib/libfftw3f_threads.a
${EWAVNEEDS_ROOT}/lib/libfftw3.a
${EWAVNEEDS_ROOT}/lib/libfftw3f.a )
#-******************************************************************************
# SUBDIRS
#-******************************************************************************
# Recurse into src
ADD_SUBDIRECTORY( src )