forked from PixarAnimationStudios/OpenUSD
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathPackages.cmake
More file actions
337 lines (299 loc) · 12.1 KB
/
Packages.cmake
File metadata and controls
337 lines (299 loc) · 12.1 KB
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
#
# Copyright 2016 Pixar
#
# Licensed under the terms set forth in the LICENSE.txt file available at
# https://openusd.org/license.
#
# Save the current value of BUILD_SHARED_LIBS and restore it at
# the end of this file, since some of the Find* modules invoked
# below may wind up stomping over this value.
set(build_shared_libs "${BUILD_SHARED_LIBS}")
# Core USD Package Requirements
# ----------------------------------------------
# Threads. Save the libraries needed in PXR_THREAD_LIBS; we may modify
# them later. We need the threads package because some platforms require
# it when using C++ functions from #include <thread>.
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
find_package(Threads REQUIRED)
set(PXR_THREAD_LIBS "${CMAKE_THREAD_LIBS_INIT}")
if(PXR_ENABLE_PYTHON_SUPPORT OR PXR_ENABLE_OPENVDB_SUPPORT)
# Find Boost package before getting any boost specific components as we need to
# disable boost-provided cmake config, based on the boost version found.
#
# XXX:
# Boost is currently required even when PXR_USE_BOOST_PYTHON is OFF, since
# pxr_boost::python still relies on header-only boost libraries.
find_package(Boost REQUIRED)
# Boost provided cmake files (introduced in boost version 1.70) result in
# inconsistent build failures on different platforms, when trying to find boost
# component dependencies like python, etc. Refer some related
# discussions:
# https://github.com/boostorg/python/issues/262#issuecomment-483069294
# https://github.com/boostorg/boost_install/issues/12#issuecomment-508683006
#
# Hence to avoid issues with Boost provided cmake config, Boost_NO_BOOST_CMAKE
# is enabled by default for boost version 1.70 and above. If a user explicitly
# set Boost_NO_BOOST_CMAKE to Off, following will be a no-op.
option(Boost_NO_BOOST_CMAKE "Disable boost-provided cmake config" ON)
if (Boost_NO_BOOST_CMAKE)
message(STATUS "Disabling boost-provided cmake config")
endif()
endif()
if(PXR_ENABLE_PYTHON_SUPPORT)
# 1--Python.
macro(setup_python_package package)
find_package(${package} COMPONENTS Interpreter Development REQUIRED)
# Set up versionless variables so that downstream libraries don't
# have to worry about which Python version is being used.
set(PYTHON_EXECUTABLE "${${package}_EXECUTABLE}")
set(PYTHON_INCLUDE_DIRS "${${package}_INCLUDE_DIRS}")
set(PYTHON_VERSION_MAJOR "${${package}_VERSION_MAJOR}")
set(PYTHON_VERSION_MINOR "${${package}_VERSION_MINOR}")
# Convert paths to CMake path format on Windows to avoid string parsing
# issues when we pass PYTHON_EXECUTABLE or PYTHON_INCLUDE_DIRS to
# pxr_library or other functions.
if(WIN32)
file(TO_CMAKE_PATH ${PYTHON_EXECUTABLE} PYTHON_EXECUTABLE)
file(TO_CMAKE_PATH ${PYTHON_INCLUDE_DIRS} PYTHON_INCLUDE_DIRS)
endif()
# PXR_PY_UNDEFINED_DYNAMIC_LOOKUP might be explicitly set when
# packaging wheels, or when cross compiling to a Python environment
# that is not the current interpreter environment.
# If it was not explicitly set to ON or OFF, then determine whether
# Python was statically linked to its runtime library by fetching the
# sysconfig variable LDLIBRARY, and set the variable accordingly.
# If the variable does not exist, PXR_PY_UNDEFINED_DYNAMIC_LOOKUP will
# default to OFF. On Windows, LDLIBRARY does not exist, as the default
# will always be OFF.
if((NOT WIN32) AND (NOT DEFINED PXR_PY_UNDEFINED_DYNAMIC_LOOKUP))
execute_process(COMMAND ${PYTHON_EXECUTABLE} "-c" "import sysconfig;print(sysconfig.get_config_var('LDLIBRARY'))"
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE PXR_PYTHON_LINKED_LIBRARY
)
get_filename_component(PXR_PYTHON_LINKED_LIBRARY_EXT ${PXR_PYTHON_LINKED_LIBRARY} LAST_EXT)
if(PXR_PYTHON_LINKED_LIBRARY_EXT STREQUAL ".a")
set(PXR_PY_UNDEFINED_DYNAMIC_LOOKUP ON)
message(STATUS
"PXR_PY_UNDEFINED_DYNAMIC_LOOKUP wasn't specified, forced ON because Python statically links ${PXR_PYTHON_LINKED_LIBRARY}")
endif()
endif()
# This option indicates that we don't want to explicitly link to the
# python libraries. See BUILDING.md for details.
if(PXR_PY_UNDEFINED_DYNAMIC_LOOKUP AND NOT WIN32)
set(PYTHON_LIBRARIES "")
else()
set(PYTHON_LIBRARIES "${package}::Python")
endif()
endmacro()
# USD builds only work with Python3
setup_python_package(Python3)
if(PXR_USE_BOOST_PYTHON)
if(WIN32 AND PXR_USE_DEBUG_PYTHON)
set(Boost_USE_DEBUG_PYTHON ON)
endif()
# Manually specify VS2022, 2019, and 2017 as USD's supported compiler versions
if(WIN32)
set(Boost_COMPILER "-vc143;-vc142;-vc141")
endif()
# As of boost 1.67 the boost_python component name includes the
# associated Python version (e.g. python27, python36).
# XXX: After boost 1.73, boost provided config files should be able to
# work without specifying a python version!
# https://github.com/boostorg/boost_install/blob/master/BoostConfig.cmake
# Find the component under the versioned name and then set the generic
# Boost_PYTHON_LIBRARY variable so that we don't have to duplicate this
# logic in each library's CMakeLists.txt.
set(python_version_nodot "${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}")
find_package(Boost
COMPONENTS
python${python_version_nodot}
REQUIRED
)
set(Boost_PYTHON_LIBRARY "${Boost_PYTHON${python_version_nodot}_LIBRARY}")
endif()
# --Jinja2
find_package(Jinja2)
else()
# -- Python
# A Python interpreter is still required for certain build options.
if (PXR_BUILD_DOCUMENTATION OR PXR_BUILD_TESTS
OR PXR_VALIDATE_GENERATED_CODE)
# We only need to check for Python3 components
find_package(Python3 COMPONENTS Interpreter)
set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE})
endif()
endif()
# --TBB
find_package(TBB REQUIRED COMPONENTS tbb)
add_definitions(${TBB_DEFINITIONS})
# --math
if(WIN32)
# Math functions are linked automatically by including math.h on Windows.
set(M_LIB "")
else()
set(M_LIB m)
endif()
if (NOT PXR_MALLOC_LIBRARY)
if (NOT WIN32)
message(STATUS "Using default system allocator because PXR_MALLOC_LIBRARY is unspecified")
endif()
endif()
# Developer Options Package Requirements
# ----------------------------------------------
if (PXR_BUILD_DOCUMENTATION)
find_program(DOXYGEN_EXECUTABLE
NAMES doxygen
)
if (EXISTS ${DOXYGEN_EXECUTABLE})
message(STATUS "Found doxygen: ${DOXYGEN_EXECUTABLE}")
else()
message(FATAL_ERROR
"doxygen not found, required for PXR_BUILD_DOCUMENTATION")
endif()
if (PXR_BUILD_HTML_DOCUMENTATION)
find_program(DOT_EXECUTABLE
NAMES dot
)
if (EXISTS ${DOT_EXECUTABLE})
message(STATUS "Found dot: ${DOT_EXECUTABLE}")
else()
message(FATAL_ERROR
"dot not found, required for PXR_BUILD_DOCUMENTATION")
endif()
endif()
endif()
# Imaging Components Package Requirements
# ----------------------------------------------
if (PXR_BUILD_IMAGING)
# --OpenImageIO
if (PXR_BUILD_OPENIMAGEIO_PLUGIN)
set(REQUIRES_Imath TRUE)
find_package(OpenImageIO REQUIRED)
add_definitions(-DPXR_OIIO_PLUGIN_ENABLED)
if (OIIO_idiff_BINARY)
set(IMAGE_DIFF_TOOL ${OIIO_idiff_BINARY} CACHE STRING "Uses idiff for image diffing")
endif()
endif()
# --OpenColorIO
if (PXR_BUILD_OPENCOLORIO_PLUGIN)
find_package(OpenColorIO REQUIRED)
add_definitions(-DPXR_OCIO_PLUGIN_ENABLED)
endif()
# --OpenGL
if (PXR_ENABLE_GL_SUPPORT)
# Prefer legacy GL library over GLVND libraries if both
# are installed.
if (POLICY CMP0072)
cmake_policy(SET CMP0072 OLD)
endif()
find_package(OpenGL REQUIRED)
add_definitions(-DPXR_GL_SUPPORT_ENABLED)
endif()
# --Metal
if (PXR_ENABLE_METAL_SUPPORT)
add_definitions(-DPXR_METAL_SUPPORT_ENABLED)
endif()
if (PXR_ENABLE_VULKAN_SUPPORT)
message(STATUS "Enabling experimental feature Vulkan support")
if (EXISTS $ENV{VULKAN_SDK})
# Prioritize the VULKAN_SDK includes and packages before any system
# installed headers. This is to prevent linking against older SDKs
# that may be installed by the OS.
# XXX This is fixed in cmake 3.18+
include_directories(BEFORE SYSTEM $ENV{VULKAN_SDK} $ENV{VULKAN_SDK}/include $ENV{VULKAN_SDK}/lib $ENV{VULKAN_SDK}/source)
set(ENV{PATH} "$ENV{VULKAN_SDK}:$ENV{VULKAN_SDK}/include:$ENV{VULKAN_SDK}/lib:$ENV{VULKAN_SDK}/source:$ENV{PATH}")
find_package(Vulkan REQUIRED)
list(APPEND VULKAN_LIBS Vulkan::Vulkan)
# Find the extra vulkan libraries we need
set(EXTRA_VULKAN_LIBS shaderc_combined)
if (WIN32 AND CMAKE_BUILD_TYPE STREQUAL "Debug")
set(EXTRA_VULKAN_LIBS shaderc_combinedd)
endif()
foreach(EXTRA_LIBRARY ${EXTRA_VULKAN_LIBS})
find_library("${EXTRA_LIBRARY}_PATH" NAMES "${EXTRA_LIBRARY}" PATHS $ENV{VULKAN_SDK}/lib)
list(APPEND VULKAN_LIBS "${${EXTRA_LIBRARY}_PATH}")
endforeach()
# Find the OS specific libs we need
if (UNIX AND NOT APPLE)
find_package(X11 REQUIRED)
list(APPEND VULKAN_LIBS ${X11_LIBRARIES})
elseif (WIN32)
# No extra libs required
endif()
add_definitions(-DPXR_VULKAN_SUPPORT_ENABLED)
else()
message(FATAL_ERROR "VULKAN_SDK not valid")
endif()
endif()
# --Opensubdiv
set(OPENSUBDIV_USE_GPU ${PXR_ENABLE_GL_SUPPORT} OR PXR_APPLE_EMBEDDED)
find_package(OpenSubdiv 3 REQUIRED)
# --Ptex
if (PXR_ENABLE_PTEX_SUPPORT)
find_package(PTex REQUIRED)
add_definitions(-DPXR_PTEX_SUPPORT_ENABLED)
endif()
# --OpenVDB
if (PXR_ENABLE_OPENVDB_SUPPORT)
set(REQUIRES_Imath TRUE)
find_package(OpenVDB REQUIRED)
add_definitions(-DPXR_OPENVDB_SUPPORT_ENABLED)
endif()
# --X11
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
find_package(X11)
endif()
# --Embree
if (PXR_BUILD_EMBREE_PLUGIN)
find_package(Embree REQUIRED)
endif()
endif()
if (PXR_BUILD_USDVIEW)
# --PySide
find_package(PySide REQUIRED)
# --PyOpenGL
find_package(PyOpenGL REQUIRED)
endif()
# Third Party Plugin Package Requirements
# ----------------------------------------------
if (PXR_BUILD_PRMAN_PLUGIN)
find_package(Renderman REQUIRED)
endif()
if (PXR_BUILD_ALEMBIC_PLUGIN)
find_package(Alembic REQUIRED)
set(REQUIRES_Imath TRUE)
if (PXR_ENABLE_HDF5_SUPPORT)
find_package(HDF5 REQUIRED
COMPONENTS
HL
REQUIRED
)
endif()
endif()
if (PXR_BUILD_DRACO_PLUGIN)
find_package(Draco REQUIRED)
endif()
if (PXR_ENABLE_MATERIALX_SUPPORT)
find_package(MaterialX REQUIRED)
add_definitions(-DPXR_MATERIALX_SUPPORT_ENABLED)
endif()
if(PXR_ENABLE_OSL_SUPPORT)
find_package(OSL REQUIRED)
set(REQUIRES_Imath TRUE)
add_definitions(-DPXR_OSL_SUPPORT_ENABLED)
endif()
if (PXR_BUILD_ANIMX_TESTS)
find_package(AnimX REQUIRED)
endif()
# ----------------------------------------------
# Try and find Imath or fallback to OpenEXR
# Use ImathConfig.cmake,
# Refer: https://github.com/AcademySoftwareFoundation/Imath/blob/main/docs/PortingGuide2-3.md#openexrimath-3x-only
if(REQUIRES_Imath)
find_package(Imath CONFIG)
if (NOT Imath_FOUND)
MESSAGE(STATUS "Imath not found. Looking for OpenEXR instead.")
find_package(OpenEXR REQUIRED)
endif()
endif()
set(BUILD_SHARED_LIBS "${build_shared_libs}")