-
Notifications
You must be signed in to change notification settings - Fork 612
/
Copy pathexternalpackages.cmake
365 lines (312 loc) · 15.2 KB
/
externalpackages.cmake
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 Contributors to the OpenImageIO project.
# SPDX-License-Identifier: Apache-2.0
# https://github.com/AcademySoftwareFoundation/OpenImageIO
###########################################################################
# Find external dependencies
###########################################################################
if (NOT VERBOSE)
set (Boost_FIND_QUIETLY true)
set (PkgConfig_FIND_QUIETLY true)
set (Threads_FIND_QUIETLY true)
endif ()
message (STATUS "${ColorBoldWhite}")
message (STATUS "* Checking for dependencies...")
message (STATUS "* - Missing a dependency 'Package'?")
message (STATUS "* Try cmake -DPackage_ROOT=path or set environment var Package_ROOT=path")
message (STATUS "* For many dependencies, we supply src/build-scripts/build_Package.bash")
message (STATUS "* - To exclude an optional dependency (even if found),")
message (STATUS "* -DUSE_Package=OFF or set environment var USE_Package=OFF ")
message (STATUS "${ColorReset}")
set (OIIO_LOCAL_DEPS_PATH "${CMAKE_SOURCE_DIR}/ext/dist" CACHE STRING
"Local area for dependencies added to CMAKE_PREFIX_PATH")
list (APPEND CMAKE_PREFIX_PATH ${OIIO_LOCAL_DEPS_PATH})
include (ExternalProject)
option (BUILD_MISSING_DEPS "Try to download and build any missing dependencies" OFF)
include (FindThreads)
###########################################################################
# Boost setup
if (MSVC)
# Disable automatic linking using pragma comment(lib,...) of boost libraries upon including of a header
add_definitions (-DBOOST_ALL_NO_LIB=1)
endif ()
# If the build system hasn't been specifically told how to link Boost, link it the same way as other
# OIIO dependencies:
if (NOT DEFINED Boost_USE_STATIC_LIBS)
set (Boost_USE_STATIC_LIBS "${LINKSTATIC}")
endif ()
if (MSVC)
# Not linking Boost as static libraries: either an explicit setting or LINKSTATIC is FALSE:
if (NOT Boost_USE_STATIC_LIBS)
add_definitions (-DBOOST_ALL_DYN_LINK=1)
endif ()
endif ()
set (Boost_COMPONENTS thread)
if (NOT USE_STD_FILESYSTEM)
list (APPEND Boost_COMPONENTS filesystem)
endif ()
message (STATUS "Boost_COMPONENTS = ${Boost_COMPONENTS}")
# The FindBoost.cmake interface is broken if it uses boost's installed
# cmake output (e.g. boost 1.70.0, cmake <= 3.14). Specifically it fails
# to set the expected variables printed below. So until that's fixed
# force FindBoost.cmake to use the original brute force path.
if (NOT DEFINED Boost_NO_BOOST_CMAKE)
set (Boost_NO_BOOST_CMAKE ON)
endif ()
checked_find_package (Boost REQUIRED
VERSION_MIN 1.53
COMPONENTS ${Boost_COMPONENTS}
RECOMMEND_MIN 1.66
RECOMMEND_MIN_REASON "Boost 1.66 is the oldest version our CI tests against"
PRINT Boost_INCLUDE_DIRS Boost_LIBRARIES )
# On Linux, Boost 1.55 and higher seems to need to link against -lrt
if (CMAKE_SYSTEM_NAME MATCHES "Linux"
AND ${Boost_VERSION} VERSION_GREATER_EQUAL 105500)
list (APPEND Boost_LIBRARIES "rt")
endif ()
include_directories (SYSTEM "${Boost_INCLUDE_DIRS}")
link_directories ("${Boost_LIBRARY_DIRS}")
option (OIIO_DISABLE_BOOST_STACKTRACE "Disable use of Boost stacktrace." OFF)
# end Boost setup
###########################################################################
###########################################################################
# Dependencies for required formats and features. These are so critical
# that we will not complete the build if they are not found.
checked_find_package (ZLIB REQUIRED) # Needed by several packages
checked_find_package (TIFF REQUIRED
VERSION_MIN 3.9
RECOMMEND_MIN 4.0
RECOMMEND_MIN_REASON "to support >4GB files")
# IlmBase & OpenEXR
checked_find_package (OpenEXR REQUIRED
VERSION_MIN 2.4
RECOMMEND_MIN 3.1
PRINT IMATH_INCLUDES OPENEXR_INCLUDES)
# Force Imath includes to be before everything else to ensure that we have
# the right Imath/OpenEXR version, not some older version in the system
# library. This shouldn't be necessary, except for the common case of people
# building against Imath/OpenEXR 3.x when there is still a system-level
# install version of 2.x.
include_directories(BEFORE ${IMATH_INCLUDES} ${OPENEXR_INCLUDES})
if (MSVC AND NOT LINKSTATIC)
add_definitions (-DOPENEXR_DLL) # Is this needed for new versions?
endif ()
if (OpenEXR_VERSION VERSION_GREATER_EQUAL 3.0)
set (OIIO_USING_IMATH 3)
else ()
set (OIIO_USING_IMATH 2)
endif ()
set (OPENIMAGEIO_IMATH_TARGETS
# For OpenEXR/Imath 3.x:
$<TARGET_NAME_IF_EXISTS:Imath::Imath>
$<TARGET_NAME_IF_EXISTS:Imath::Half>
# For OpenEXR >= 2.4/2.5 with reliable exported targets
$<TARGET_NAME_IF_EXISTS:IlmBase::Imath>
$<TARGET_NAME_IF_EXISTS:IlmBase::Half>
$<TARGET_NAME_IF_EXISTS:IlmBase::Iex> )
set (OPENIMAGEIO_OPENEXR_TARGETS
# For OpenEXR/Imath 3.x:
$<TARGET_NAME_IF_EXISTS:OpenEXR::OpenEXR>
# For OpenEXR >= 2.4/2.5 with reliable exported targets
$<TARGET_NAME_IF_EXISTS:OpenEXR::IlmImf>
$<TARGET_NAME_IF_EXISTS:IlmBase::IlmThread>
$<TARGET_NAME_IF_EXISTS:IlmBase::Iex> )
set (OPENIMAGEIO_IMATH_DEPENDENCY_VISIBILITY "PUBLIC" CACHE STRING
"Should we expose Imath library dependency as PUBLIC or PRIVATE")
set (OPENIMAGEIO_CONFIG_DO_NOT_FIND_IMATH OFF CACHE BOOL
"Exclude find_dependency(Imath) from the exported OpenImageIOConfig.cmake")
# JPEG -- prefer JPEG-Turbo to regular libjpeg
checked_find_package (libjpeg-turbo
VERSION_MIN 2.1
DEFINITIONS -DUSE_JPEG_TURBO=1)
if (NOT TARGET libjpeg-turbo::jpeg) # Try to find the non-turbo version
checked_find_package (JPEG REQUIRED)
endif ()
# Pugixml setup. Normally we just use the version bundled with oiio, but
# some linux distros are quite particular about having separate packages so we
# allow this to be overridden to use the distro-provided package if desired.
option (USE_EXTERNAL_PUGIXML "Use an externally built shared library version of the pugixml library" OFF)
if (USE_EXTERNAL_PUGIXML)
checked_find_package (pugixml REQUIRED
VERSION_MIN 1.8
DEFINITIONS -DUSE_EXTERNAL_PUGIXML=1)
else ()
message (STATUS "Using internal PugiXML")
endif()
# From pythonutils.cmake
find_python()
###########################################################################
# Dependencies for optional formats and features. If these are not found,
# we will continue building, but the related functionality will be disabled.
checked_find_package (PNG)
checked_find_package (BZip2) # Used by ffmpeg and freetype
if (NOT BZIP2_FOUND)
set (BZIP2_LIBRARIES "") # TODO: why does it break without this?
endif ()
checked_find_package (Freetype
DEFINITIONS -DUSE_FREETYPE=1 )
checked_find_package (OpenColorIO
DEFINITIONS -DUSE_OCIO=1 -DUSE_OPENCOLORIO=1
# PREFER_CONFIG
)
if (OpenColorIO_FOUND)
option (OIIO_DISABLE_BUILTIN_OCIO_CONFIGS
"For deveoper debugging/testing ONLY! Disable OCIO 2.2 builtin configs." OFF)
if (OIIO_DISABLE_BUILTIN_OCIO_CONFIGS OR "$ENV{OIIO_DISABLE_BUILTIN_OCIO_CONFIGS}")
add_compile_definitions(OIIO_DISABLE_BUILTIN_OCIO_CONFIGS)
endif ()
else ()
set (OpenColorIO_FOUND 0)
endif ()
checked_find_package (OpenCV 3.0
DEFINITIONS -DUSE_OPENCV=1)
# Intel TBB
set (TBB_USE_DEBUG_BUILD OFF)
checked_find_package (TBB 2017
SETVARIABLES OIIO_TBB
PREFER_CONFIG)
checked_find_package (DCMTK VERSION_MIN 3.6.1) # For DICOM images
checked_find_package (FFmpeg VERSION_MIN 3.0)
checked_find_package (GIF
VERSION_MIN 4
RECOMMEND_MIN 5.0
RECOMMEND_MIN_REASON "for stability and thread safety")
# For HEIF/HEIC/AVIF formats
checked_find_package (Libheif VERSION_MIN 1.3
RECOMMEND_MIN 1.7
RECOMMEND_MIN_REASON "for AVIF support")
if (APPLE AND LIBHEIF_VERSION VERSION_GREATER_EQUAL 1.10 AND LIBHEIF_VERSION VERSION_LESS 1.11)
message (WARNING "Libheif 1.10 on Apple is known to be broken, disabling libheif support")
set (Libheif_FOUND 0)
endif ()
checked_find_package (LibRaw
VERSION_MIN 0.18
PRINT LibRaw_r_LIBRARIES)
if (LibRaw_FOUND AND LibRaw_VERSION VERSION_LESS 0.20 AND CMAKE_CXX_STANDARD VERSION_GREATER_EQUAL 17)
message (STATUS "${ColorYellow}WARNING When building for C++17, LibRaw should be 0.20 or higher (found ${LibRaw_VERSION}). You may get errors, depending on the compiler.${ColorReset}")
# Currently, we issue the above warning and let them take their chances.
# If we wish to disable the LibRaw<0.20/C++17 combination that may fail,
# just uncomment the following two lines.
# set (LibRaw_FOUND 0)
# set (LIBRAW_FOUND 0)
endif ()
checked_find_package (OpenJPEG VERSION_MIN 2.0
RECOMMEND_MIN 2.2
RECOMMEND_MIN_REASON "for multithreading support")
# Note: Recent OpenJPEG versions have exported cmake configs, but we don't
# find them reliable at all, so we stick to our FindOpenJPEG.cmake module.
checked_find_package (OpenVDB
VERSION_MIN 5.0
DEPS TBB
DEFINITIONS -DUSE_OPENVDB=1)
if (OpenVDB_FOUND AND OpenVDB_VERSION VERSION_GREATER_EQUAL 10.1 AND CMAKE_CXX_STANDARD VERSION_LESS 17)
message (WARNING "${ColorYellow}OpenVDB >= 10.1 (we found ${OpenVDB_VERSION}) can only be used when we build with C++17 or higher. Disabling OpenVDB support.${ColorReset}")
set (OpeVDB_FOUND 0)
endif ()
checked_find_package (Ptex PREFER_CONFIG)
if (NOT Ptex_FOUND OR NOT Ptex_VERSION)
# Fallback for inadequate Ptex exported configs. This will eventually
# disappear when we can 100% trust Ptex's exports.
unset (Ptex_FOUND)
checked_find_package (Ptex)
endif ()
checked_find_package (WebP)
option (USE_R3DSDK "Enable R3DSDK (RED camera) support" OFF)
checked_find_package (R3DSDK) # RED camera
set (NUKE_VERSION "7.0" CACHE STRING "Nuke version to target")
checked_find_package (Nuke)
# Qt -- used for iv
option (USE_QT "Use Qt if found" ON)
if (USE_QT)
checked_find_package (OpenGL) # used for iv
endif ()
if (USE_QT AND OPENGL_FOUND)
checked_find_package (Qt6 COMPONENTS Core Gui Widgets OpenGLWidgets)
if (NOT Qt6_FOUND)
checked_find_package (Qt5 COMPONENTS Core Gui Widgets OpenGL)
endif ()
if (NOT Qt5_FOUND AND NOT Qt6_FOUND AND APPLE)
message (STATUS " If you think you installed qt with Homebrew and it still doesn't work,")
message (STATUS " try: export PATH=/usr/local/opt/qt/bin:$PATH")
endif ()
endif ()
###########################################################################
# Tessil/robin-map
option (BUILD_ROBINMAP_FORCE "Force local download/build of robin-map even if installed" OFF)
option (BUILD_MISSING_ROBINMAP "Local download/build of robin-map if not installed" ON)
set (BUILD_ROBINMAP_VERSION "v0.6.2" CACHE STRING "Preferred Tessil/robin-map version, of downloading/building our own")
macro (find_or_download_robin_map)
# If we weren't told to force our own download/build of robin-map, look
# for an installed version. Still prefer a copy that seems to be
# locally installed in this tree.
if (NOT BUILD_ROBINMAP_FORCE)
find_package (Robinmap QUIET)
endif ()
# If an external copy wasn't found and we requested that missing
# packages be built, or we we are forcing a local copy to be built, then
# download and build it.
# Download the headers from github
if ((BUILD_MISSING_ROBINMAP AND NOT ROBINMAP_FOUND) OR BUILD_ROBINMAP_FORCE)
message (STATUS "Downloading local Tessil/robin-map")
set (ROBINMAP_INSTALL_DIR "${PROJECT_SOURCE_DIR}/ext/robin-map")
set (ROBINMAP_GIT_REPOSITORY "https://github.com/Tessil/robin-map")
if (NOT IS_DIRECTORY ${ROBINMAP_INSTALL_DIR}/include/tsl)
find_package (Git REQUIRED)
execute_process(COMMAND ${GIT_EXECUTABLE} clone ${ROBINMAP_GIT_REPOSITORY} -n ${ROBINMAP_INSTALL_DIR})
execute_process(COMMAND ${GIT_EXECUTABLE} checkout ${BUILD_ROBINMAP_VERSION}
WORKING_DIRECTORY ${ROBINMAP_INSTALL_DIR})
if (IS_DIRECTORY ${ROBINMAP_INSTALL_DIR}/include/tsl)
message (STATUS "DOWNLOADED Tessil/robin-map to ${ROBINMAP_INSTALL_DIR}.\n"
"Remove that dir to get rid of it.")
else ()
message (FATAL_ERROR "Could not download Tessil/robin-map")
endif ()
endif ()
set (ROBINMAP_INCLUDE_DIR "${ROBINMAP_INSTALL_DIR}/include")
endif ()
checked_find_package (Robinmap REQUIRED)
endmacro()
###########################################################################
# fmtlib
option (BUILD_FMT_FORCE "Force local download/build of fmt even if installed" OFF)
option (BUILD_MISSING_FMT "Local download/build of fmt if not installed" ON)
option (INTERNALIZE_FMT "Copy fmt headers into <install>/include/OpenImageIO/detail/fmt" ON)
set (BUILD_FMT_VERSION "10.0.0" CACHE STRING "Preferred fmtlib/fmt version, when downloading/building our own")
macro (find_or_download_fmt)
# If we weren't told to force our own download/build of fmt, look
# for an installed version. Still prefer a copy that seems to be
# locally installed in this tree.
if (NOT BUILD_FMT_FORCE)
find_package (fmt QUIET)
endif ()
# If an external copy wasn't found and we requested that missing
# packages be built, or we we are forcing a local copy to be built, then
# download and build it.
if ((BUILD_MISSING_FMT AND NOT FMT_FOUND) OR BUILD_FMT_FORCE)
message (STATUS "Downloading local fmtlib/fmt")
set (FMT_INSTALL_DIR "${PROJECT_SOURCE_DIR}/ext/fmt")
set (FMT_GIT_REPOSITORY "https://github.com/fmtlib/fmt")
if (NOT IS_DIRECTORY ${FMT_INSTALL_DIR}/include/fmt)
find_package (Git REQUIRED)
execute_process(COMMAND ${GIT_EXECUTABLE} clone ${FMT_GIT_REPOSITORY} -n ${FMT_INSTALL_DIR})
execute_process(COMMAND ${GIT_EXECUTABLE} checkout ${BUILD_FMT_VERSION}
WORKING_DIRECTORY ${FMT_INSTALL_DIR})
if (IS_DIRECTORY ${FMT_INSTALL_DIR}/include/fmt)
message (STATUS "DOWNLOADED fmtlib/fmt to ${FMT_INSTALL_DIR}.\n"
"Remove that dir to get rid of it.")
else ()
message (FATAL_ERROR "Could not download fmtlib/fmt")
endif ()
endif ()
set (FMT_INCLUDE_DIR "${FMT_INSTALL_DIR}/include")
set (OIIO_USING_FMT_LOCAL TRUE)
else ()
set (OIIO_USING_FMT_LOCAL FALSE)
endif ()
checked_find_package (fmt REQUIRED
VERSION_MIN 7.0)
endmacro()
find_or_download_fmt()
if (FMT_VERSION VERSION_EQUAL 90100
AND GCC_VERSION VERSION_GREATER 0.0 AND NOT GCC_VERSION VERSION_GREATER 7.2)
message (WARNING "${ColorRed}fmt 9.1 is known to not work with gcc <= 7.2${ColorReset}")
endif ()