-
Notifications
You must be signed in to change notification settings - Fork 31
/
CMakeLists.txt
273 lines (236 loc) · 8.68 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
##-*****************************************************************************
##
## Copyright (c) 2009-2016,
## 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(AbcView)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
# Declare the project version
SET(PROJECT_VERSION_MAJOR "1")
SET(PROJECT_VERSION_MINOR "0")
SET(PROJECT_VERSION_PATCH "9")
SET(PROJECT_VERSION
${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
SET(VERSION ${PROJECT_VERSION})
# ------------------------------------------------------------------------------
# OPTIONS (set with -D<option>=<value>)
# ------------------------------------------------------------------------------
OPTION(USE_STATIC_BOOST "Build with static Boost libs" ON)
OPTION(USE_PYTHON "Include PyAbcOpenGL and PyQt app" ON)
OPTION(USE_SHARED_LIBS "Build shared libraries" ON)
OPTION(ABCVIEW_GLEW_LINK_STATIC "GLEW is a static library" OFF)
OPTION(ILMBASE_LINK_STATIC "IlmBase is a static library" 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 (USE_SHARED_LIBS)
SET(LIB_TYPE SHARED)
SET(ARCHIVE_INSTALL_DIR lib)
IF (WIN32)
ADD_DEFINITIONS(-DABCVIEW_DLL)
ENDIF()
ENDIF()
# 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()
# 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()
# 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 ILMBASE_LINK_STATIC)
ADD_DEFINITIONS(-DOPENEXR_DLL)
ENDIF()
IF (ABCVIEW_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{ABCVIEW_INSTALL_PREFIX})
SET(CMAKE_INSTALL_PREFIX
$ENV{ABCVIEW_INSTALL_PREFIX}/abcview-${VERSION})
ENDIF()
# Tell me what my install location would be
MESSAGE(STATUS "make install dir: ${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)
# Boost
IF (USE_PYTHON)
INCLUDE("./cmake/AbcViewBoost.cmake")
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
ENDIF()
# Alembic
FIND_PACKAGE(Alembic REQUIRED)
MESSAGE(STATUS "ALEMBIC_LIB: ${ALEMBIC_LIB}")
MESSAGE(STATUS "ALEMBIC_INCLUDE_PATH: ${ALEMBIC_INCLUDE_PATH}")
INCLUDE_DIRECTORIES(${ALEMBIC_INCLUDE_PATH})
# IlmBase
INCLUDE("./cmake/AbcViewIlmBase.cmake")
INCLUDE_DIRECTORIES(${ILMBASE_INCLUDE_DIRECTORY})
# OpenGL
FIND_PACKAGE(OpenGL REQUIRED)
FIND_PACKAGE(GLUT REQUIRED)
FIND_PACKAGE(GLEW REQUIRED)
IF (${WINDOWS})
SET(ABCVIEW_GL_LIBS
${GLEW_LIBRARY}
${GLUT_LIBRARY}
${OPENGL_LIBRARIES}
)
INCLUDE_DIRECTORIES(${GLUT_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${GLEW_INCLUDE_DIR})
ELSEIF (${DARWIN})
SET(ABCVIEW_GL_LIBS
${GLEW_LIBRARY}
${GLUT_LIBRARY}
"-framework OpenGL"
)
ELSE()
SET(ABCVIEW_GL_LIBS
${GLEW_LIBRARY}
${GLUT_LIBRARY}
${OPENGL_LIBRARIES}
)
ENDIF()
MESSAGE(STATUS "OpenGL Libraries: ${ABCVIEW_GL_LIBS}")
# ------------------------------------------------------------------------------
# BUILD LIBRARIES
# ------------------------------------------------------------------------------
SET(CORE_LIBS
${ALEMBIC_LIB}
${ILMBASE_LIBS}
${CMAKE_THREAD_LIBS_INIT}
${EXTERNAL_MATH_LIBS}
)
ADD_SUBDIRECTORY(lib)
SET(ABCOPENGL_DIR "${PROJECT_SOURCE_DIR}/lib")
MESSAGE(STATUS "ABCOPENGL_DIR: ${ABCOPENGL_DIR}")
INCLUDE_DIRECTORIES("${ABCOPENGL_DIR}" "${PROJECT_BINARY_DIR}/lib")
# ------------------------------------------------------------------------------
# BUILD PYTHON
# ------------------------------------------------------------------------------
IF (USE_PYTHON)
ADD_SUBDIRECTORY(python)
ENDIF()
# ------------------------------------------------------------------------------
# BUILD BINARIES
# ------------------------------------------------------------------------------
ADD_SUBDIRECTORY(bin)
# ------------------------------------------------------------------------------
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()