-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
257 lines (221 loc) · 9.82 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
#
# Copyright 2020 Autodesk
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
cmake_minimum_required(VERSION 3.13...3.17)
project(maya-usd)
#------------------------------------------------------------------------------
# options
#------------------------------------------------------------------------------
option(BUILD_TESTS "Build tests." ON)
option(BUILD_STRICT_MODE "Enforce all warnings as errors." ON)
option(BUILD_SHARED_LIBS "Build libraries as shared or static." ON)
option(CODE_COVERAGE "Build and collect code coverage info." OFF)
if(APPLE)
option(BUILD_UB2 "Build Universal Binary 2 (UB2) Intel64+arm64" OFF)
endif()
option(CMAKE_WANT_MATERIALX_BUILD "Enable building with MaterialX (experimental)." OFF)
set(PXR_OVERRIDE_PLUGINPATH_NAME PXR_PLUGINPATH_NAME
CACHE STRING "Name of env var USD searches to find plugins")
# Build-related information, expected to be passed in by the parent build.
set(MAYAHYDRA_BUILD_NUMBER 0 CACHE STRING "Build number.")
set(MAYAHYDRA_GIT_COMMIT "Unknown_Git_commit" CACHE STRING "Build commit.")
set(MAYAHYDRA_GIT_BRANCH "Unknown_Git_branch" CACHE STRING "Build branch.")
#------------------------------------------------------------------------------
# internal flags to control build
#------------------------------------------------------------------------------
# MAYAHYDRA_TO_USD_RELATIVE_PATH : Set this variable to any relative path from install
# folder to USD location. If defined will set relative
# rpaths for USD libraries.
#------------------------------------------------------------------------------
# global options
#------------------------------------------------------------------------------
# Avoid noisy install messages
set(CMAKE_INSTALL_MESSAGE "NEVER")
if(APPLE)
if(BUILD_UB2)
message(STATUS "Building with Universal Binary 2")
set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64")
set(CMAKE_OSX_DEPLOYMENT_TARGET 11.0)
else()
set(CMAKE_OSX_ARCHITECTURES "x86_64")
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.14)
endif()
endif()
set(CMAKE_MODULE_PATH
${CMAKE_MODULE_PATH}
${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules
)
# Use RUNPATH instead of RPATH for all shared libs, executables and modules on Linux
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") # IS_LINUX not yet defined
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--enable-new-dtags")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--enable-new-dtags")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--enable-new-dtags")
endif()
#------------------------------------------------------------------------------
# modules and definitions
#------------------------------------------------------------------------------
include(cmake/utils.cmake)
find_package(Maya 2024 REQUIRED)
if(APPLE AND BUILD_UB2 AND NOT MAYA_MACOSX_BUILT_WITH_UB2)
message(WARNING "Maya was NOT built with Universal Binary 2")
endif()
include(cmake/mayahydra_version.info)
set(MAYAHYDRA_VERSION "${MAYAHYDRA_MAJOR_VERSION}.${MAYAHYDRA_MINOR_VERSION}.${MAYAHYDRA_PATCH_LEVEL}")
include(cmake/flowViewport_version.info)
set(FLOWVIEWPORT_VERSION "${FLOWVIEWPORT_MAJOR_VERSION}.${FLOWVIEWPORT_MINOR_VERSION}.${FLOWVIEWPORT_PATCH_LEVEL}")
set(DEFAULT_PYTHON_3_VERSION 3.10)
if (MAYA_APP_VERSION VERSION_GREATER 2024)
set(DEFAULT_PYTHON_3_VERSION 3.11)
endif()
if (NOT BUILD_WITH_PYTHON_3_VERSION)
set(BUILD_WITH_PYTHON_3_VERSION ${DEFAULT_PYTHON_3_VERSION})
endif()
if (DEFINED PYTHON_INCLUDE_DIR AND DEFINED PYTHON_LIBRARIES AND DEFINED Python_EXECUTABLE)
SET(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}")
SET(PYTHONLIBS_FOUND TRUE)
# Use the Python module to find the python lib.
find_package(Python ${BUILD_WITH_PYTHON_3_VERSION} EXACT REQUIRED COMPONENTS Interpreter)
if(NOT Python_Interpreter_FOUND)
set(PYTHONLIBS_FOUND FALSE)
endif()
endif()
if (NOT PYTHONLIBS_FOUND)
include(cmake/python.cmake)
endif()
message(STATUS "Build mayaHydra with Python3 = " ${BUILD_WITH_PYTHON_3_VERSION})
message(STATUS " PYTHON_INCLUDE_DIRS = ${PYTHON_INCLUDE_DIRS}")
message(STATUS " PYTHON_LIBRARIES = ${PYTHON_LIBRARIES}")
message(STATUS " Python_EXECUTABLE = ${Python_EXECUTABLE}")
find_package(USD 0.22.11 REQUIRED)
if (CMAKE_WANT_MATERIALX_BUILD)
# Requires at least USD 22.11 for hdMtlx module and USD must have been built with MaterialX:
if(NOT TARGET hdMtlx)
set(CMAKE_WANT_MATERIALX_BUILD OFF)
message(WARNING "Disabling MaterialX VP2 rendering: it is not supported by this USD package.")
endif()
endif()
include(cmake/usd.cmake)
set(CONFIGURABLE_DECIMAL_STREAMING_AVAILABLE FALSE)
if (DEFINED PXR_USD_LOCATION)
file(GLOB_RECURSE STRING_UTILS_HEADER_PATH
LIST_DIRECTORIES FALSE
"${PXR_USD_LOCATION}/include/**stringUtils.h")
file(READ ${STRING_UTILS_HEADER_PATH} STRING_UTILS_HEADER_CONTENTS)
string(REGEX MATCH "struct TfDecimalToStringConfig" DECIMAL_TO_STRING_MATCH ${STRING_UTILS_HEADER_CONTENTS})
if (DECIMAL_TO_STRING_MATCH)
set(CONFIGURABLE_DECIMAL_STREAMING_AVAILABLE TRUE)
endif()
endif()
option(BUILD_MAYAHYDRALIB "Build the Maya-To-Hydra plugin and scene delegate." ON)
find_package(UFE REQUIRED)
if(UFE_FOUND)
message(STATUS "Building with UFE ${UFE_VERSION}.")
else()
message(STATUS "UFE not found.")
endif()
find_package(MayaUsd)
if(MayaUsd_FOUND)
message(STATUS "Building with MayaUsd.")
else()
message(STATUS "MayaUsd not used to build.")
endif()
if(CMAKE_WANT_MATERIALX_BUILD AND MAYA_LIGHTAPI_VERSION LESS 2)
set(CMAKE_WANT_MATERIALX_BUILD OFF)
message(WARNING "Disabling MaterialX VP2 rendering: it is not supported by this version of Maya.")
endif()
if(TARGET hdMtlx)
# MaterialX was built into USD. We need to know where to find MaterialX targets.
find_package(MaterialX REQUIRED)
if(TARGET MaterialXCore)
message(STATUS "Found MaterialX")
endif()
endif()
if(MAYA_APP_VERSION VERSION_GREATER 2024)
# Look for Qt6 in the Maya devkit.
# The Qt6 archive in the Maya devkit contains everything needed for the normal cmake find_package.
set(CMAKE_PREFIX_PATH "${MAYA_DEVKIT_LOCATION}/Qt")
set(WANT_QT_VERSION 6.5)
find_package(Qt6 ${WANT_QT_VERSION} COMPONENTS Core Widgets QUIET)
if (Qt6_FOUND)
if (CODE_COVERAGE)
set(BUILD_HDSB_PLUGIN FALSE)
message(STATUS "Code coverage enabled, Hydra Scene Browser will not be built.")
else()
set(BUILD_HDSB_PLUGIN TRUE)
message(STATUS "Found Qt ${Qt6_VERSION} in Maya devkit. Hydra Scene Browser will be built.")
endif()
else()
message(WARNING "Could not find Qt ${WANT_QT_VERSION} in Maya devkit directory: ${MAYA_DEVKIT_LOCATION}. \
You must extract Qt.tar.gz. Hydra Scene Browser will not be built.")
endif()
else()
message(WARNING "Maya ${MAYA_APP_VERSION} does not contain Qt6 in its devkit. \
Hydra Scene Browser will not be built.")
endif()
#------------------------------------------------------------------------------
# compiler configuration
#------------------------------------------------------------------------------
include(cmake/compiler_config.cmake)
#------------------------------------------------------------------------------
# gulrak filesystem
#------------------------------------------------------------------------------
include(cmake/gulrak.cmake)
#------------------------------------------------------------------------------
# test
#------------------------------------------------------------------------------
if (BUILD_TESTS)
include(cmake/googletest.cmake)
include(cmake/test.cmake)
fetch_googletest()
enable_testing()
add_subdirectory(test)
endif()
#------------------------------------------------------------------------------
# lib
#------------------------------------------------------------------------------
add_subdirectory(lib)
if(BUILD_HDSB_PLUGIN)
add_subdirectory(lib/adskHydraSceneBrowser)
endif()
#------------------------------------------------------------------------------
# plugin
#------------------------------------------------------------------------------
if(BUILD_HDSB_PLUGIN)
add_subdirectory(plugin/mayaHydraSceneBrowser)
if (BUILD_TESTS)
add_subdirectory(plugin/mayaHydraSceneBrowserTest)
endif()
endif()
#------------------------------------------------------------------------------
# scripts
#------------------------------------------------------------------------------
add_subdirectory(scripts)
#------------------------------------------------------------------------------
# install
#------------------------------------------------------------------------------
if (DEFINED MAYAHYDRA_TO_USD_RELATIVE_PATH)
set(USD_INSTALL_LOCATION "${CMAKE_INSTALL_PREFIX}/${MAYAHYDRA_TO_USD_RELATIVE_PATH}")
else()
set(USD_INSTALL_LOCATION ${PXR_USD_LOCATION})
endif()
#------------------------------------------------------------------------------
# Maya module files
#------------------------------------------------------------------------------
if (IS_WINDOWS)
configure_file("modules/mayaHydra_Win.mod.template" ${PROJECT_BINARY_DIR}/mayaHydra.mod)
else()
configure_file("modules/mayaHydra.mod.template" ${PROJECT_BINARY_DIR}/mayaHydra.mod)
endif()
install(FILES ${PROJECT_BINARY_DIR}/mayaHydra.mod DESTINATION ${CMAKE_INSTALL_PREFIX})