forked from AcademySoftwareFoundation/OpenColorIO
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
executable file
·254 lines (177 loc) · 8.35 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
# SPDX-License-Identifier: BSD-3-Clause
# Copyright Contributors to the OpenColorIO Project.
###############################################################################
# CMake definition.
cmake_minimum_required(VERSION 3.12)
set(CMAKE_MODULE_PATH
${CMAKE_MODULE_PATH}
${CMAKE_SOURCE_DIR}/share/cmake/utils
${CMAKE_SOURCE_DIR}/share/cmake/macros
${CMAKE_SOURCE_DIR}/share/cmake/modules
)
set(CMAKE_WARN_DEPRECATED ON)
if(APPLE AND NOT DEFINED CMAKE_OSX_DEPLOYMENT_TARGET)
# The value of this variable should be set prior to the first project() command invocation
# because it may influence configuration of the toolchain and flags.
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13" CACHE STRING "Minimum OS X deployment version")
endif()
###############################################################################
# Project definition.
project(OpenColorIO
VERSION 2.0.0
DESCRIPTION "OpenColorIO (OCIO) is a complete color management solution"
HOMEPAGE_URL https://github.com/AcademySoftwareFoundation/OpenColorIO
LANGUAGES CXX C)
# "dev", "beta1", rc1", etc or "" for an official release.
set(OpenColorIO_VERSION_RELEASE_TYPE "beta2")
enable_testing()
###############################################################################
# Forbid in-source build.
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message(FATAL_ERROR
"In-source build not allowed. Please make a new sub-directory and run cmake from there.")
endif()
###############################################################################
# Global CMake options.
# Do not output install messages.
if(NOT DEFINED CMAKE_INSTALL_MESSAGE)
set(CMAKE_INSTALL_MESSAGE "NEVER")
endif()
# Change the path max size to avoid problem on Windows.
if(NOT DEFINED CMAKE_OBJECT_PATH_MAX)
set(CMAKE_OBJECT_PATH_MAX 300)
endif()
###############################################################################
# Define compilation mode i.e. debug or release
if(NOT DEFINED CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "")
message(STATUS "Setting build type to 'Release' as none was specified.")
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build." FORCE)
endif()
# List all the valid build types.
if(NOT DEFINED CMAKE_CONFIGURATION_TYPES)
set(CMAKE_CONFIGURATION_TYPES "Debug;Release;MinSizeRel;RelWithDebInfo" CACHE STRING "" FORCE)
mark_as_advanced(CMAKE_CONFIGURATION_TYPES)
endif()
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
# Is that a valid build type?
if(NOT "${CMAKE_BUILD_TYPE}" IN_LIST CMAKE_CONFIGURATION_TYPES)
string(REPLACE ";" ", " _CMAKE_CONFIGURATION_TYPES_STR "${CMAKE_CONFIGURATION_TYPES}")
message(FATAL_ERROR
"CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} is unsupported. Supported values are: ${_CMAKE_CONFIGURATION_TYPES_STR}.")
endif()
# Is that in debug mode?
set(_BUILD_TYPE_DEBUG OFF)
if(CMAKE_BUILD_TYPE MATCHES "[Dd][Ee][Bb][Uu][Gg]")
set(_BUILD_TYPE_DEBUG ON)
endif()
set(BUILD_TYPE_DEBUG ${_BUILD_TYPE_DEBUG})
###############################################################################
# C++ version configuration
include(Compilers)
include(CppVersion)
###############################################################################
# Components to build
option(BUILD_SHARED_LIBS "Set to OFF to build static libraries" ON)
option(OCIO_BUILD_APPS "Set to OFF to disable command-line apps" ON)
option(OCIO_BUILD_NUKE "Specify whether to build nuke plugins" OFF)
option(OCIO_BUILD_DOCS "Specify whether to build documentation" OFF)
option(OCIO_BUILD_TESTS "Specify whether to build unittests" ON)
option(OCIO_BUILD_GPU_TESTS "Specify whether to build gpu unittests" ON)
option(OCIO_USE_HEADLESS "Specify whether the GPU rendering is headless" OFF)
option(OCIO_BUILD_PYTHON "Specify whether to build python bindings" ON)
option(OCIO_BUILD_JAVA "Specify whether to build java bindings" OFF)
option(OCIO_WARNING_AS_ERROR "Set build error level for CI testing" OFF)
###############################################################################
# Optimization / internal linking preferences
option(OCIO_USE_SSE "Specify whether to enable SSE CPU performance optimizations" ON)
option(OCIO_INLINES_HIDDEN "Specify whether to build with -fvisibility-inlines-hidden" ${UNIX})
###############################################################################
# Supplemental builtins
# Add supplemental built-in transformations such as camera related one.
option(OCIO_ADD_EXTRA_BUILTINS "Specify whether to add supplemental built-in transforms" ON)
###############################################################################
# GPU configuration
include(CheckSupportGL)
###############################################################################
# Define compilation and link flags
include(CompilerFlags)
###############################################################################
# External linking options
# Supported options
set(_EXT_OPTIONS NONE MISSING ALL)
string(REPLACE ";" ", " _EXT_OPTIONS_STR "${_EXT_OPTIONS}")
# Default option
set(_OCIO_INSTALL_EXT_PACKAGES "MISSING")
if(DEFINED OCIO_INSTALL_EXT_PACKAGES)
# Case insensitive match
string(TOUPPER "${OCIO_INSTALL_EXT_PACKAGES}" _OCIO_INSTALL_EXT_PACKAGES)
if(NOT "${_OCIO_INSTALL_EXT_PACKAGES}" IN_LIST _EXT_OPTIONS)
message(FATAL_ERROR
"OCIO_INSTALL_EXT_PACKAGES=${OCIO_INSTALL_EXT_PACKAGES} is unsupported. Supported values are: ${_EXT_OPTIONS_STR}.")
endif()
endif()
# Overwrite cache variable with normalized case
set(OCIO_INSTALL_EXT_PACKAGES "${_OCIO_INSTALL_EXT_PACKAGES}" CACHE STRING
"Set the condition for Installing external dependencies" FORCE)
set_property(CACHE OCIO_INSTALL_EXT_PACKAGES PROPERTY STRINGS ${_EXT_OPTIONS})
###############################################################################
# Versioning
if(NOT DEFINED SOVERSION)
set(SOVERSION "${OpenColorIO_VERSION_MAJOR}.${OpenColorIO_VERSION_MINOR}" CACHE STRING
"Set the SO version in the SO name of the output library")
message(STATUS "Setting SOVERSION to '${SOVERSION}' as none was specified.")
elseif(SOVERSION STREQUAL "")
message(FATAL_ERROR "A SOVERSION cannot be empty.")
endif()
###############################################################################
# Namespace
if(NOT DEFINED OCIO_NAMESPACE)
set(OCIO_NAMESPACE OpenColorIO CACHE STRING
"Specify the master OCIO C++ namespace: Options include OpenColorIO OpenColorIO_<YOURFACILITY> etc.")
message(STATUS "Setting namespace to '${OCIO_NAMESPACE}' as none was specified.")
elseif(OCIO_NAMESPACE STREQUAL "")
message(FATAL_ERROR "A namespace cannot be empty.")
endif()
###############################################################################
# Library name custom suffix
# This helps an application that needs to ship a dynamic library OCIO ensure
# that it has a unique name that won't conflict with one elsewhere on the
# system.
set (OCIO_LIBNAME_SUFFIX "" CACHE STRING
"Specify a suffix to all libraries that are built")
###############################################################################
# Error checking
if(OCIO_BUILD_SHARED AND OCIO_BUILD_STATIC)
message(FATAL_ERROR
"Deprecated options OCIO_BUILD_SHARED and OCIO_BUILD_STATIC cannot both be used at once")
endif()
if(OCIO_BUILD_SHARED)
message(DEPRECATION
"Option OCIO_BUILD_SHARED is deprecated. Please use the cmake standard BUILD_SHARED_LIBS=ON (default ON)")
if(NOT BUILD_SHARED_LIBS)
set(BUILD_SHARED_LIBS ON)
endif()
endif()
if(OCIO_BUILD_STATIC)
message(DEPRECATION
"Option OCIO_BUILD_STATIC is deprecated. Please use the cmake standard BUILD_SHARED_LIBS=OFF (default ON)")
if(BUILD_SHARED_LIBS)
set(BUILD_SHARED_LIBS OFF)
endif()
endif()
###############################################################################
# Find or install external dependencies
# Some required targets may be created by third-party CMake configs, which
# don't generally produce global targets. To guarantee all imported targets are
# global, this module is included at the project root level.
include(FindExtPackages)
###############################################################################
# Progress to other sources
add_subdirectory(ext)
add_subdirectory(include)
add_subdirectory(src)
add_subdirectory(tests)
if(OCIO_BUILD_DOCS)
add_subdirectory(docs)
endif()
add_subdirectory(vendor)