forked from Autodesk/bifrost-usd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
196 lines (161 loc) · 7.8 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
#-
#*****************************************************************************
# Copyright 2022 Autodesk, Inc.
#
# 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.20 FATAL_ERROR)
message(STATUS "CMake version: ${CMAKE_VERSION}")
# A calling package (other CMake) can set the package name
# Note: The USD Pack that is shipped with Bifrost is named `usd_pack` and it is
# loaded by default by Bifrost.
# Here we must use a different name for this custom/standalone build of
# the pack, so the USD Pack from Bifrost's installation directory can be
# disabled when needed and replaced by this one.
if( NOT BIFUSD_PACKAGE_NAME )
set(BIFUSD_PACKAGE_NAME bifrost_usd_pack)
endif()
include(cmake/version.info)
# Enable no language yet.
project(${BIFUSD_PACKAGE_NAME}
VERSION ${BIFROST_USD_PACK_MAJOR_VERSION}.${BIFROST_USD_PACK_MINOR_VERSION}.${BIFROST_USD_PACK_PATCH_LEVEL}
LANGUAGES NONE)
include(CMakePrintHelpers)
# Generates a 'compile_commands.json' file containing the exact compilation
# command for all translation units of the project in a machine-readable form.
#
# Useful for many offline tools and very useful for debugging the build.
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
#==============================================================================
# Define common build variables
#==============================================================================
set(BIFUSD_CMAKE_DIR "${PROJECT_SOURCE_DIR}/cmake")
set(BIFUSD_TOOLS_DIR "${BIFUSD_CMAKE_DIR}/bifusd")
set(BIFUSD_MAJOR_VERSION ${BIFROST_USD_PACK_MAJOR_VERSION})
set(BIFUSD_MINOR_VERSION ${BIFROST_USD_PACK_MINOR_VERSION})
set(BIFUSD_PATCH_LEVEL ${BIFROST_USD_PACK_PATCH_LEVEL})
set(BIFUSD_PRODUCT_NAME "\"Bifrost USD pack\"")
#==============================================================================
# Target/Property for json files
#==============================================================================
# This target and property needs to be forward declared before utils.cmake.
# because bifusd_header_parser refers to them. More deps/properties are added
# to the target later.
#
if( NOT TARGET ${BIFUSD_PACKAGE_NAME}_config_info)
add_custom_target(${BIFUSD_PACKAGE_NAME}_config_info)
endif()
# Add property to collect the list of generated json files.
set_target_properties(${BIFUSD_PACKAGE_NAME}_config_info PROPERTIES
BIFROST_USD_PACK_ALL_JSON_FILES "")
#==============================================================================
# General setup
# This defines functions and macros that used later on; in particular
# in setup.cmake and the compiler setup.
#==============================================================================
include(${BIFUSD_TOOLS_DIR}/utils.cmake)
include(${BIFUSD_TOOLS_DIR}/setup.cmake)
include(${BIFUSD_TOOLS_DIR}/version.cmake)
#==============================================================================
# PACKAGES USED WHILE BUILDING
#==============================================================================
set(BIFUSD_USE_PYTHON_VERSION 3 CACHE STRING "The Python version used.")
include(${BIFUSD_TOOLS_DIR}/python.cmake)
#==============================================================================
# Local setup
#==============================================================================
include(cmake/setup.cmake)
include(cmake/utils.cmake)
# Standalone build setup the compiler
# Else use the parent environment's compiler
if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
#==============================================================================
# COMPILER
#==============================================================================
# Include the file configuring the compiler used on the given platform.
# Enabling the languages and set the compiler flags after the project
# has been configured follows the suggestion in:
#
# http://www.cmake.org/Bug/print_bug_page.php?bug_id=11942
set(CMAKE_USER_MAKE_RULES_OVERRIDE "${BIFUSD_TOOLS_DIR}/compiler_${CMAKE_SYSTEM_NAME}.cmake")
#==============================================================================
# LANGUAGES
#==============================================================================
# The platform setup needs to be called before enable_language
# It will setup the platform's SDK location, when necessary.
include(${BIFUSD_TOOLS_DIR}/platform_sdk_${CMAKE_SYSTEM_NAME}.cmake)
# Enabling the languages and set the compiler flags after the project
# has been configured follows the suggestion in:
#
# http://www.cmake.org/Bug/print_bug_page.php?bug_id=11942
enable_language(CXX)
# Finalize the various build variants now that the C++ language has been
# enabled.
include(${BIFUSD_TOOLS_DIR}/final_compiler_setup.cmake)
else()
include(${BIFUSD_TOOLS_DIR}/compiler_config.cmake)
endif()
#==============================================================================
# PACKAGING - uses CPack
#==============================================================================
include(${BIFUSD_TOOLS_DIR}/package.cmake)
#==============================================================================
# 3rd-parties
#==============================================================================
#==============================================================================
# TESTING
#==============================================================================
include(${BIFUSD_TOOLS_DIR}/gtest.cmake)
#==============================================================================
# Import/Find installed packages
#==============================================================================
find_package(Bifrost REQUIRED SDK)
find_package(USD REQUIRED)
#==============================================================================
# BIFUSD SUBDIRECTORIES
#==============================================================================
add_subdirectory(${BIFUSD_TOOLS_DIR}/src/config)
add_subdirectory(${BIFUSD_TOOLS_DIR}/src/versioning)
#==============================================================================
# SUBDIRECTORIES
#==============================================================================
print_settings()
add_subdirectory(src)
add_subdirectory(doc)
# Test resources can be set from the outside.
# This allows having the test data in a downloaded archive, for example.
if( NOT BIFUSD_TEST_RESOURCES_LOCATION )
set( BIFUSD_TEST_RESOURCES_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/test")
endif()
enable_testing()
add_subdirectory(utils/test)
add_subdirectory(test)
#==============================================================================
# HOST PLUGINS - TRANSLATION TABLES AND OTHERS
#==============================================================================
#
# Maya
if( MAYA_RUNTIME_LOCATION)
find_package( Bifrost REQUIRED Maya)
add_subdirectory(maya_plugin)
endif()
#==============================================================================
# FINALIZE
#==============================================================================
# Publish the findUSD module helper
install(
FILES ${BIFUSD_CMAKE_DIR}/modules/FindUSD.cmake
DESTINATION ${BIFUSD_INSTALL_CMAKE_DIR}/modules )
include( ${BIFUSD_TOOLS_DIR}/finalize.cmake)