forked from alembicmaya/alembic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
365 lines (322 loc) · 11.3 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
##-*****************************************************************************
##
## Copyright (c) 2009-2015,
## Sony Pictures Imageworks Inc. and
## Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd.
##
## All rights reserved.
##
## Redistribution and use in source and binary forms, with or without
## modification, are permitted provided that the following conditions are
## met:
## * Redistributions of source code must retain the above copyright
## notice, this list of conditions and the following disclaimer.
## * Redistributions in binary form must reproduce the above
## copyright notice, this list of conditions and the following disclaimer
## in the documentation and/or other materials provided with the
## distribution.
## * Neither the name of Industrial Light & Magic nor the names of
## its contributors may be used to endorse or promote products derived
## from this software without specific prior written permission.
##
## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
##
##-*****************************************************************************
PROJECT(Alembic)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
MESSAGE(STATUS "CMAKE SYSTEM NAME: ${CMAKE_SYSTEM_NAME}")
IF (RUN_FROM_MK)
SET(CMAKE_FIRST_RUN CACHE STRING "CMake initialised from mk script")
MARK_AS_ADVANCED (CMAKE_FIRST_RUN)
ENDIF()
IF (NOT DEFINED QUIET)
SET(CMAKE_VERBOSE_MAKEFILE TRUE)
ENDIF()
# Declare the project version
SET(PROJECT_VERSION_MAJOR "1")
SET(PROJECT_VERSION_MINOR "5")
SET(PROJECT_VERSION_PATCH "8")
SET(PROJECT_VERSION
${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
SET(VERSION ${PROJECT_VERSION})
#-******************************************************************************
# OPTIONS (set with -D<option>=<value>)
#-******************************************************************************
OPTION(USE_ARNOLD "Include Arnold stuff" OFF)
OPTION(USE_EXAMPLES "Include examples" OFF)
OPTION(USE_HDF5 "Include HDF5 stuff" ON)
OPTION(USE_MAYA "Include Maya stuff" OFF)
OPTION(USE_OPENGL "Include AbcOpenGL lib" OFF)
OPTION(USE_PRMAN "Include PRMan stuff" OFF)
OPTION(USE_PYALEMBIC "Include PyAlembic stuff" OFF)
OPTION(USE_STATIC_BOOST "Build with static Boost libs" ON)
OPTION(USE_STATIC_HDF5 "Build with static HDF5 libs" OFF)
OPTION(USE_TESTS "Include Alembic tests" ON)
OPTION(ALEMBIC_GLEW_LINK_STATIC "GLEW is a static library" OFF)
OPTION(ALEMBIC_ILMBASE_LINK_STATIC "IlmBase is a static library" OFF)
OPTION(ALEMBIC_SHARED_LIBS "Build shared libraries" ON)
OPTION(ALEMBIC_LIB_USES_BOOST
"Main Alembic library uses boost for things like shared_ptr" OFF)
OPTION(ALEMBIC_LIB_USES_TR1
"Main Alembic library uses std::tr1 for things like shared_ptr" OFF)
# Set static/dynamic build options
SET(LIB_TYPE STATIC)
SET(RUNTIME_INSTALL_DIR lib)
SET(LIBRARY_INSTALL_DIR lib)
SET(ARCHIVE_INSTALL_DIR lib)
IF (ALEMBIC_SHARED_LIBS)
SET(LIB_TYPE SHARED)
SET(ARCHIVE_INSTALL_DIR lib)
IF (WIN32)
ADD_DEFINITIONS(-DALEMBIC_DLL)
ENDIF()
ENDIF(ALEMBIC_SHARED_LIBS)
# Cmake system specific flags
SET(WINDOWS FALSE)
IF ("${CMAKE_SYSTEM_NAME}" MATCHES "Windows")
SET(WINDOWS TRUE)
ENDIF()
SET(DARWIN FALSE)
IF ("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
SET(DARWIN TRUE)
# suppress rpath warning
IF (POLICY CMP0042)
CMAKE_POLICY(SET CMP0042 OLD)
ENDIF()
ENDIF()
SET(LINUX FALSE)
IF ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
SET(LINUX TRUE)
ENDIF()
IF (NOT ${ALEMBIC_LIB_USES_TR1} AND NOT ${ALEMBIC_LIB_USES_BOOST})
# TODO figure out how to do this for Windows
INCLUDE(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
IF (COMPILER_SUPPORTS_CXX1X)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
ELSEIF (COMPILER_SUPPORTS_CXX0X)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
ENDIF()
ENDIF()
# Set visibility for GNU compilers
IF (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")
ENDIF()
# Set some debug vs opt flags
IF ("${CMAKE_BUILD_TYPE}" MATCHES "Debug")
ADD_DEFINITIONS(-DDEBUG=1 -UNDEBUG)
IF (NOT WINDOWS)
ADD_DEFINITIONS(-Wall -Werror -Wextra -Wno-unused-parameter)
ENDIF()
ELSEIF ("${CMAKE_BUILD_TYPE}" MATCHES "Release")
ADD_DEFINITIONS(-DNDEBUG=1 -UDEBUG)
IF (NOT WINDOWS)
ADD_DEFINITIONS(-O3)
ENDIF()
ENDIF()
IF (NOT ${WINDOWS})
SET(EXTERNAL_MATH_LIBS "-lm")
ELSE()
SET(EXTERNAL_MATH_LIBS "")
ENDIF()
IF (${WINDOWS})
ADD_DEFINITIONS(-DPLATFORM_WINDOWS -DPLATFORM=WINDOWS)
IF (NOT ALEMBIC_ILMBASE_LINK_STATIC)
ADD_DEFINITIONS(-DOPENEXR_DLL)
ENDIF()
IF (USE_OPENGL AND ALEMBIC_GLEW_LINK_STATIC)
ADD_DEFINITIONS(-DGLEW_STATIC)
ENDIF()
ELSEIF (${DARWIN})
#ADD_DEFINITIONS(-DPLATFORM_DARWIN -DPLATFORM=DARWIN "-arch x86_64")
ADD_DEFINITIONS(-DPLATFORM_DARWIN -DPLATFORM=DARWIN)
ELSE()
ADD_DEFINITIONS(-DPLATFORM_LINUX -DPLATFORM=LINUX)
ENDIF()
#-******************************************************************************
# INSTALLATION
#-******************************************************************************
IF (DEFINED ENV{ALEMBIC_INSTALL_PREFIX})
SET( CMAKE_INSTALL_PREFIX
$ENV{ALEMBIC_INSTALL_PREFIX}/alembic-${VERSION})
ENDIF()
# Tell me what my install location would be
MESSAGE(STATUS "The install dir is ${CMAKE_INSTALL_PREFIX}")
# check in the source directory
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake/Modules)
#-******************************************************************************
# TESTS
#-******************************************************************************
# Globally enable testing
ENABLE_TESTING()
IF (BUILD_TESTING)
SET(BUILDNAME "${BUILDNAME}" CACHE STRING "Name of build on the dashboard")
MARK_AS_ADVANCED(BUILDNAME)
ENDIF(BUILD_TESTING)
IF (UNIX AND NOT WINDOWS)
FIND_PROGRAM(CMAKE_UNAME uname /bin /usr/bin /usr/local/bin )
IF (CMAKE_UNAME)
EXEC_PROGRAM(uname ARGS -m OUTPUT_VARIABLE CMAKE_SYSTEM_PROCESSOR)
SET(CMAKE_SYSTEM_PROCESSOR ${CMAKE_SYSTEM_PROCESSOR} CACHE INTERNAL
"processor type (i386 and x86_64)")
IF(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
ADD_DEFINITIONS(-fPIC)
ENDIF(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
ENDIF(CMAKE_UNAME)
ENDIF(UNIX AND NOT WINDOWS)
IF (DARWIN)
ADD_DEFINITIONS(-fPIC)
ENDIF()
#-******************************************************************************
# DEPENDENCIES
#-******************************************************************************
FIND_PACKAGE(Threads REQUIRED)
# We only need boost if including PyAlembic, or using it in the lib
IF (ALEMBIC_LIB_USES_BOOST OR USE_PYALEMBIC)
INCLUDE("./cmake/AlembicBoost.cmake")
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
ENDIF()
# IlmBase
INCLUDE("./cmake/AlembicIlmBase.cmake")
INCLUDE_DIRECTORIES(${ALEMBIC_ILMBASE_INCLUDE_DIRECTORY})
# OpenGL
IF (USE_OPENGL)
FIND_PACKAGE(OpenGL REQUIRED)
FIND_PACKAGE(GLUT REQUIRED)
FIND_PACKAGE(GLEW REQUIRED)
IF (${WINDOWS})
SET(ALEMBIC_GL_LIBS
${GLEW_LIBRARY}
${GLUT_LIBRARY}
${OPENGL_LIBRARIES}
)
INCLUDE_DIRECTORIES(${GLUT_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${GLEW_INCLUDE_DIR})
ELSEIF (${DARWIN})
SET(ALEMBIC_GL_LIBS
${GLEW_LIBRARY}
${GLUT_LIBRARY}
"-framework OpenGL"
)
ELSE()
SET(ALEMBIC_GL_LIBS
${GLEW_LIBRARY}
${GLUT_LIBRARY}
${OPENGL_LIBRARIES}
)
ENDIF()
MESSAGE(STATUS "OpenGL Libraries: ${ALEMBIC_GL_LIBS}")
ENDIF()
# HDF5
IF (USE_HDF5)
FIND_PACKAGE(ZLIB REQUIRED)
SET(ALEMBIC_WITH_HDF5 "1")
INCLUDE("./cmake/AlembicHDF5.cmake")
INCLUDE_DIRECTORIES(${HDF5_INCLUDE_DIRS})
ENDIF()
#-******************************************************************************
# BUILD LIBRARIES
#-******************************************************************************
IF (USE_HDF5)
SET(CORE_LIBS
Alembic
${HDF5_LIBRARIES}
${ALEMBIC_ILMBASE_LIBS}
${CMAKE_THREAD_LIBS_INIT}
${ZLIB_LIBRARIES}
${EXTERNAL_MATH_LIBS}
)
ELSE()
SET(CORE_LIBS
Alembic
${ALEMBIC_ILMBASE_LIBS}
${CMAKE_THREAD_LIBS_INIT}
${EXTERNAL_MATH_LIBS}
)
ENDIF()
# Alembic, AbcOpenGL
ADD_SUBDIRECTORY(lib)
INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/lib" "${PROJECT_BINARY_DIR}/lib")
# PyAlembic, PyAbcOpenGL
IF (USE_PYALEMBIC)
INCLUDE("./cmake/AlembicPyIlmBase.cmake")
INCLUDE("./cmake/AlembicPython.cmake")
INCLUDE_DIRECTORIES(${ALEMBIC_PYILMBASE_INCLUDE_DIRECTORY})
ADD_SUBDIRECTORY(python)
ENDIF()
#-******************************************************************************
# BUILD BINARIES
#-******************************************************************************
# PRMan
IF (USE_PRMAN)
INCLUDE("./cmake/AlembicPRMan.cmake")
IF (${ALEMBIC_PRMAN_FOUND})
MESSAGE(STATUS "Building PRMan plugins")
ADD_SUBDIRECTORY(prman)
ELSE()
MESSAGE(STATUS "PRMan not found")
ENDIF()
ENDIF()
# Arnold
IF (USE_ARNOLD)
INCLUDE("./cmake/AlembicArnold.cmake")
IF (${ALEMBIC_ARNOLD_FOUND})
MESSAGE(STATUS "Building Arnold plugins")
ADD_SUBDIRECTORY( arnold )
ELSE()
MESSAGE(STATUS "Arnold not found")
ENDIF()
ENDIF()
# Maya
IF (USE_MAYA)
INCLUDE("./cmake/AlembicMaya.cmake")
IF (MAYA_FOUND)
MESSAGE(STATUS "Building Maya plugins")
ADD_SUBDIRECTORY(maya)
ELSE()
MESSAGE(STATUS "Maya not found")
ENDIF()
ENDIF()
# Examples
IF (USE_EXAMPLES)
ADD_SUBDIRECTORY(examples)
ENDIF()
#-******************************************************************************
SET(_config_msg "\n * Alembic Configuration ===")
MACRO(info_cfg_option
_setting)
SET(_msg " * ${_setting}")
STRING(LENGTH "${_msg}" _len)
WHILE("36" GREATER "${_len}")
SET(_msg "${_msg} ")
MATH(EXPR _len "${_len} + 1")
ENDWHILE()
SET(_config_msg "${_config_msg}\n${_msg}${${_setting}}")
ENDMACRO()
info_cfg_option(USE_ARNOLD)
info_cfg_option(USE_EXAMPLES)
info_cfg_option(USE_HDF5)
info_cfg_option(USE_MAYA)
info_cfg_option(USE_OPENGL)
info_cfg_option(USE_PRMAN)
info_cfg_option(USE_PYALEMBIC)
info_cfg_option(USE_STATIC_BOOST)
info_cfg_option(USE_STATIC_HDF5)
info_cfg_option(USE_TESTS)
info_cfg_option(ALEMBIC_GLEW_LINK_STATIC)
info_cfg_option(ALEMBIC_ILMBASE_LINK_STATIC)
info_cfg_option(ALEMBIC_SHARED_LIBS)
info_cfg_option(ALEMBIC_LIB_USES_BOOST)
info_cfg_option(ALEMBIC_LIB_USES_TR1)
MESSAGE("${_config_msg}")