forked from AcademySoftwareFoundation/OpenColorIO
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
406 lines (339 loc) · 15.4 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
project(OpenColorIO)
set(OCIO_VERSION_MAJOR 1)
set(OCIO_VERSION_MINOR 0)
set(OCIO_VERSION_PATCH 8)
cmake_minimum_required(VERSION 2.8)
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/share/cmake)
if(NOT DEFINED CMAKE_FIRST_RUN)
SET(CMAKE_FIRST_RUN 1 CACHE INTERNAL "")
endif()
###############################################################################
### GLOBAL ###
option(OCIO_BUILD_SHARED "Set to OFF to disable building the shared core library" ON)
option(OCIO_BUILD_STATIC "Set to OFF to disable building the static core library" ON)
option(OCIO_BUILD_TRUELIGHT "Set to OFF to disable truelight" ON)
option(OCIO_BUILD_APPS "Set to OFF to disable command-line apps" ON)
option(OCIO_BUILD_NUKE "Set to OFF to disable building nuke plugins" ON)
option(OCIO_BUILD_DOCS "Specify whether to build documentation" OFF)
option(OCIO_BUILD_TESTS "Specify whether to build unittests" OFF)
option(OCIO_BUILD_PYGLUE "Specify whether to build python bindings" ON)
option(OCIO_BUILD_JNIGLUE "Specify whether to build java bindings" OFF)
option(OCIO_STATIC_JNIGLUE "Specify whether to statically link ocio to the java bindings" ON)
option(OCIO_USE_SSE "Specify whether to enable SSE CPU performance optimizations" ON)
# Use boost's shared_ptr by default on Windows (as <VS2010 doesn't have it),
# Use std::tr1::shared_ptr by default on other platforms
option(OCIO_USE_BOOST_PTR "Set to ON to enable boost shared_ptr (necessary when tr1 is not available)" WIN32)
option(OCIO_PYGLUE_LINK "If ON, link the Python module to the core shared library" OFF)
option(OCIO_PYGLUE_RESPECT_ABI "If ON, the Python module install path includes Python UCS version" OFF)
option(OCIO_PYGLUE_SONAME "If ON, soname/soversion will be set for Python module library" OFF)
option(OCIO_PYGLUE_LIB_PREFIX "If ON, prefix the Python module with 'lib'" OFF)
if(UNIX AND NOT APPLE)
option(USE_EXTERNAL_YAML "Use system installed yaml-cpp library." OFF)
option(USE_EXTERNAL_TINYXML "Use system installed tinyxml library." OFF)
option(USE_EXTERNAL_LCMS "Use system install lcms2 library." OFF)
endif()
# This does not include the SOVERSION override, on purpose, so that the
# OCIO_VERSION value will be an accurate reflection of the underlying library version.
set(OCIO_VERSION "${OCIO_VERSION_MAJOR}.${OCIO_VERSION_MINOR}.${OCIO_VERSION_PATCH}")
if(NOT SOVERSION)
set(SOVERSION ${OCIO_VERSION_MAJOR} CACHE STRING "Set the SO version in the SO name of the output library")
endif()
###############################################################################
include(ParseArguments)
include(OCIOMacros)
include(ExternalProject)
enable_language(CXX)
ENABLE_TESTING()
if(APPLE OR IPHONE)
if(NOT CMAKE_OSX_ARCHITECTURES)
set(CMAKE_OSX_ARCHITECTURES x86_64 CACHE STRING
"Setting OSX Architectures, options are: ppc;i386;ppc64;x86_64"
FORCE)
endif()
if(CMAKE_FIRST_RUN)
message(STATUS "Setting OSX Architectures to: ${CMAKE_OSX_ARCHITECTURES}")
endif()
endif()
# Set the default built type
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
FORCE)
endif(NOT CMAKE_BUILD_TYPE)
if(CMAKE_FIRST_RUN)
message(STATUS "Setting Build Type to: ${CMAKE_BUILD_TYPE}")
endif()
# Set the default namespace
if(NOT OCIO_NAMESPACE)
set(OCIO_NAMESPACE OpenColorIO CACHE STRING
"Specify the master OCIO C++ namespace: Options include OpenColorIO OpenColorIO_<YOURFACILITY> etc."
FORCE)
endif(NOT OCIO_NAMESPACE)
messageonce("Setting Namespace to: ${OCIO_NAMESPACE}")
# If CMAKE_INSTALL_EXEC_PREFIX is not specified, install binaries
# directly into the regular install prefix
if(NOT CMAKE_INSTALL_EXEC_PREFIX)
messageonce("Exec prefix not specified, defaulting to ${CMAKE_INSTALL_PREFIX}")
set(CMAKE_INSTALL_EXEC_PREFIX ${CMAKE_INSTALL_PREFIX})
endif()
messageonce("Use Boost Ptr: ${OCIO_USE_BOOST_PTR}")
if(OCIO_USE_BOOST_PTR)
set(Boost_ADDITIONAL_VERSIONS "1.49" "1.45" "1.44" "1.43" "1.43.0" "1.42"
"1.42.0" "1.41" "1.41.0" "1.40"
"1.40.0" "1.39" "1.39.0" "1.38"
"1.38.0" "1.37" "1.37.0" "1.34.1"
"1_34_1")
set(Boost_USE_MULTITHREADED ON)
find_package(Boost 1.34)
if(NOT Boost_FOUND)
message(FATAL_ERROR "OCIO_USE_BOOST_PTR is specified, but a boost installation could not be found.")
else()
set(OCIO_USE_BOOST_PTR 1)
endif()
set(EXTERNAL_INCLUDE_DIRS ${EXTERNAL_INCLUDE_DIRS} ${Boost_INCLUDE_DIR})
# set(EXTERNAL_LIBRARIES ${EXTERNAL_LIBRARIES} ${Boost_LIB_DIAGNOSTIC_DEFINITIONS})
else()
set(OCIO_USE_BOOST_PTR 0)
endif()
if(CMAKE_COMPILER_IS_GNUCXX)
# Enable a bunch of compiler warnings...
# http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wshadow -Wconversion -Wcast-qual -Wformat=2")
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic")
endif(CMAKE_COMPILER_IS_GNUCXX)
if(WIN32)
if(PYTHON_VERSION AND PYTHON_INCLUDE AND PYTHON_LIB)
set(EXTDIST_PYTHONPATH ${PYTHON_LIB}/python${PYTHON_VARIANT_PATH}/site-packages)
set(PYTHONPATH ${EXTDIST_PYTHONPATH};$ENV{PYTHONPATH})
set(PYTHON_OK YES)
message(STATUS "Setting Python path to: ${PYTHONPATH}")
endif()
else()
# Find Python, used for (possibly) building pyglue, and now to
# construct the external project path
OCIOFindPython()
set(EXTDIST_ROOT ${CMAKE_BINARY_DIR}/ext/dist)
set(EXTDIST_BINPATH ${EXTDIST_ROOT}/bin)
if(PYTHON_OK)
set(EXTDIST_PYTHONPATH ${EXTDIST_ROOT}/lib/python${PYTHON_VERSION}/site-packages)
set(PYTHONPATH ${EXTDIST_PYTHONPATH}:$ENV{PYTHONPATH})
endif()
endif()
messageonce("Setting EXTDIST_BINPATH: ${EXTDIST_BINPATH}")
messageonce("Setting EXTDIST_PYTHONPATH: ${EXTDIST_PYTHONPATH}")
###############################################################################
### tinyxml ###
if(USE_EXTERNAL_TINYXML)
set(TINYXML_VERSION_MIN "2.6.1")
find_package(TinyXML)
if(TINYXML_FOUND)
if(TINYXML_VERSION VERSION_EQUAL ${TINYXML_VERSION_MIN} OR
TINYXML_VERSION VERSION_GREATER ${TINYXML_VERSION_MIN})
message(STATUS "External TinyXML will be used.")
else()
message(FATAL_ERROR "ERROR: ${TINYXML_VERSION} found, but ${TINYXML_VERSION_MIN} or newer is required.")
endif()
else(TINYXML_FOUND)
message(STATUS "TinyXML was not found. Perhaps you forgot to install the development package?")
endif(TINYXML_FOUND)
else(USE_EXTERNAL_TINYXML)
set(TINYXML_VERSION 2_6_1)
set(TINYXML_CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${PROJECT_BINARY_DIR}/ext/dist)
if(CMAKE_TOOLCHAIN_FILE)
set(TINYXML_CMAKE_ARGS ${TINYXML_CMAKE_ARGS} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE})
endif()
ExternalProject_Add(tinyxml
URL ${CMAKE_SOURCE_DIR}/ext/tinyxml_${TINYXML_VERSION}.tar.gz
PATCH_COMMAND patch -f -p1 < ${CMAKE_SOURCE_DIR}/ext/tinyxml_${TINYXML_VERSION}.patch
BINARY_DIR ext/build/tinyxml
INSTALL_DIR ext/dist
CMAKE_ARGS ${TINYXML_CMAKE_ARGS}
)
if(WIN32)
set(TINYXML_STATIC_LIBRARIES ${PROJECT_BINARY_DIR}/ext/dist/lib/tinyxml.lib)
else()
set(TINYXML_STATIC_LIBRARIES ${PROJECT_BINARY_DIR}/ext/dist/lib/libtinyxml.a)
endif()
endif(USE_EXTERNAL_TINYXML)
###############################################################################
### YAML ###
if(USE_EXTERNAL_YAML)
# Set minimum yaml version for non-patched sources.
set(YAML_VERSION_MIN "0.3.0")
include(FindPkgConfig)
pkg_check_modules(YAML_CPP yaml-cpp)
if(YAML_CPP_FOUND)
if(YAML_CPP_VERSION VERSION_EQUAL ${YAML_VERSION_MIN} OR
YAML_CPP_VERSION VERSION_GREATER ${YAML_VERSION_MIN})
message(STATUS "System yaml-cpp library will be used.")
include_directories(BEFORE ${YAML_CPP_INCLUDE_DIRS})
else()
message(FATAL_ERROR "ERROR: yaml-cpp ${YAML_VERSION_MIN} or greater is required.")
endif()
else(YAML_CPP_FOUND)
message(FATAL_ERROR "ERROR: System yaml-cpp library was not found. Make sure the library is installed and the pkg-config file exists.")
endif(YAML_CPP_FOUND)
else(USE_EXTERNAL_YAML)
set(YAML_CPP_VERSION 0.3.0)
set(YAML_CPP_CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${PROJECT_BINARY_DIR}/ext/dist -DYAML_CPP_BUILD_TOOLS:BOOL=FALSE)
if(CMAKE_TOOLCHAIN_FILE)
set(YAML_CPP_CMAKE_ARGS ${YAML_CPP_CMAKE_ARGS} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE})
endif()
ExternalProject_Add(YAML_CPP_LOCAL
URL ${CMAKE_SOURCE_DIR}/ext/yaml-cpp-${YAML_CPP_VERSION}.tar.gz
BINARY_DIR ext/build/yaml-cpp
PATCH_COMMAND patch -p1 < ${CMAKE_SOURCE_DIR}/ext/yaml-cpp-${YAML_CPP_VERSION}.patch
INSTALL_DIR ext/dist
CMAKE_ARGS ${YAML_CPP_CMAKE_ARGS}
)
set(YAML_CPP_INCLUDE_DIRS ${PROJECT_BINARY_DIR}/ext/dist/include)
set(YAML_CPP_LIBRARY_DIRS ${PROJECT_BINARY_DIR}/ext/dist/lib)
if(WIN32)
set(YAML_CPP_STATIC_DEBUG_LIBRARIES ${PROJECT_BINARY_DIR}/ext/dist/lib/libyaml-cppmdd.lib)
set(YAML_CPP_STATIC_OPTIMIZED_LIBRARIES ${PROJECT_BINARY_DIR}/ext/dist/lib/libyaml-cppmd.lib)
else()
set(YAML_CPP_STATIC_GENERAL_LIBRARIES ${PROJECT_BINARY_DIR}/ext/dist/lib/libyaml-cpp.a)
endif()
endif(USE_EXTERNAL_YAML)
###############################################################################
### Externals ###
set(EXTERNAL_INCLUDE_DIRS ${EXTERNAL_INCLUDE_DIRS} ${PROJECT_BINARY_DIR}/ext/dist/include)
set(EXTERNAL_COMPILE_FLAGS "-DTIXML_USE_STL")
if(CMAKE_COMPILER_IS_GNUCXX)
execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion
OUTPUT_VARIABLE GCC_VERSION)
if (GCC_VERSION VERSION_LESS 4.2)
message(STATUS "GCC Version < 4.2 - symbol visibility hiding disabled")
set(EXTERNAL_COMPILE_FLAGS "${EXTERNAL_COMPILE_FLAGS} -fPIC")
else()
set(EXTERNAL_COMPILE_FLAGS "${EXTERNAL_COMPILE_FLAGS} -fPIC -fvisibility-inlines-hidden -fvisibility=hidden")
endif()
endif()
set(EXTERNAL_LINK_FLAGS "")
set(EXTERNAL_LIBRARY_DIRS ${PROJECT_BINARY_DIR}/ext/dist/lib)
set(EXTERNAL_DEBUG_LIBRARIES ${YAML_CPP_STATIC_DEBUG_LIBRARIES})
set(EXTERNAL_OPTIMIZED_LIBRARIES ${YAML_CPP_STATIC_OPTIMIZED_LIBRARIES})
set(EXTERNAL_GENERAL_LIBRARIES ${TINYXML_STATIC_LIBRARIES} ${YAML_CPP_STATIC_GENERAL_LIBRARIES})
###############################################################################
### Documentation ###
messageonce("Generate Documentation: ${OCIO_BUILD_DOCS}")
if(OCIO_BUILD_DOCS)
if(PYTHON_OK)
add_subdirectory(docs)
else()
message(STATUS "Building the documentation requires Python, but locating Python failed: ${PYTHON_ERR}")
endif()
endif()
###############################################################################
### SSE ###
messageonce("SSE Optimizations: ${OCIO_USE_SSE}")
if(OCIO_USE_SSE)
if(WIN32)
# SSE instructions are automatically compiled into 64-bit applications so enabling the option is redundant and
# actually produces an unknown option warning in Visual Studio.
if(NOT CMAKE_CL_64)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:SSE2")
endif()
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse2")
endif()
add_definitions("-DUSE_SSE")
endif()
###############################################################################
### TRUELIGHT ###
if(OCIO_BUILD_TRUELIGHT)
find_package(Truelight)
if(TRUELIGHT_FOUND)
messageonce("Will build the truelight transform support against ${Truelight_LIBRARY_DIR}")
add_definitions(-DOCIO_TRUELIGHT_SUPPORT)
set(EXTERNAL_INCLUDE_DIRS ${EXTERNAL_INCLUDE_DIRS} ${Truelight_INCLUDE_DIR})
set(EXTERNAL_COMPILE_FLAGS "${EXTERNAL_COMPILE_FLAGS} ${Truelight_COMPILE_FLAGS}")
set(EXTERNAL_LINK_FLAGS "${EXTERNAL_LINK_FLAGS} ${Truelight_LINK_FLAGS}")
set(EXTERNAL_LIBRARIES ${EXTERNAL_LIBRARIES} ${Truelight_LIBRARIES})
else()
messageonce("Not building truelight transform support. Add the flag -D TRUELIGHT_INSTALL_PATH=... or set the TRUELIGHT_ROOT environment variable")
endif()
endif()
###############################################################################
### CORE ###
add_subdirectory(src/core)
messageonce("Build Unit Tests: ${OCIO_BUILD_TESTS}")
if(OCIO_BUILD_TESTS)
add_subdirectory(src/core_tests)
endif()
###############################################################################
### APPS ###
if(OCIO_BUILD_APPS)
# Try to find OpenImageIO (OIIO) and OpenGL stuff
OCIOFindOpenImageIO()
if(OIIO_FOUND)
add_subdirectory(src/apps/ocioconvert)
add_subdirectory(src/apps/ociolutimage)
else()
messageonce("Not building ocioconvert/ociolutimage. Requirement(s) found: OIIO:${OIIO_FOUND}")
endif()
# ociodisplay, displays color-transformed images (uses OpenImageIO,
# and OpenGL)
OCIOFindOpenGL()
if(OPENGL_FOUND AND GLUT_FOUND AND GLEW_FOUND AND OIIO_FOUND)
add_subdirectory(src/apps/ociodisplay)
else()
messageonce("Not building ociodisplay. Requirement(s) found, OpenGL:${OPENGL_FOUND}, GLUT:${GLUT_FOUND}, GLEW:${GLEW_FOUND}, OIIO:${OIIO_FOUND}")
endif()
# ociocheck: verifies an OCIO config
add_subdirectory(src/apps/ociocheck)
# ociobakelut writes out luts
add_subdirectory(src/apps/ociobakelut)
endif()
###############################################################################
### NUKE ###
if(OCIO_BUILD_NUKE)
find_package(Nuke)
if(NUKE_FOUND)
messageonce("Will build the Nuke plugins against ${Nuke_LIBRARY_DIR}")
add_subdirectory(src/nuke)
else()
messageonce("Not building Nuke plugins. Add the flag -D NUKE_INSTALL_PATH=... or set the NDK_PATH environment variable")
endif()
endif()
###############################################################################
### PYGLUE ###
if(OCIO_BUILD_PYGLUE)
if(PYTHON_OK)
add_subdirectory(src/pyglue)
else()
messageonce("Python bindings will not be built: ${PYTHON_ERR}")
endif()
endif()
###############################################################################
### JNIGLUE ###
if(OCIO_BUILD_JNIGLUE)
OCIOFindJava()
if(Java_FOUND)
add_subdirectory(src/jniglue)
else()
messageonce("Java bindings will not be built as we can't find Java")
endif()
endif()
###############################################################################
### Configure env script ###
configure_file(${CMAKE_SOURCE_DIR}/share/ocio/setup_ocio.sh.in
${CMAKE_CURRENT_BINARY_DIR}/share/ocio/setup_ocio.sh @ONLY)
INSTALL(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/share/ocio/setup_ocio.sh DESTINATION share/ocio/)
###############################################################################
### CPACK ###
set(CPACK_PACKAGE_VERSION_MAJOR ${SOVERSION})
set(CPACK_PACKAGE_VERSION_MINOR ${OCIO_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${OCIO_VERSION_PATCH})
set(CPACK_GENERATOR None)
set(CPACK_SOURCE_GENERATOR TGZ)
set(CPACK_SOURCE_PACKAGE_FILE_NAME "ocio.${OCIO_VERSION}")
include(CPack)
###############################################################################
### CTEST ###
add_custom_target(test_verbose
COMMAND ctest -VV
DEPENDS ocio_core_tests
COMMENT "Running ctest with verbose output")
# Log CMake first run done
SET(CMAKE_FIRST_RUN 0 CACHE INTERNAL "")