-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
207 lines (157 loc) · 4.81 KB
/
Copy pathCMakeLists.txt
File metadata and controls
207 lines (157 loc) · 4.81 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
cmake_minimum_required(VERSION 3.5)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(PROJECT_NAME maya_usd_export)
set(CMAKE_AUTOMOC ON)
project(${PROJECT_NAME})
# options
option(BUILD_TESTS "builds tests" OFF)
# set vars
# set from USD_LOCATION environment variable if exists
if(NOT DEFINED USD_LOCATION AND DEFINED ENV{USD_LOCATION})
set(USD_LOCATION $ENV{USD_LOCATION} CACHE PATH "Path to USD installation")
else()
set(USD_LOCATION "/opt/USD" CACHE PATH "Path to USD installation")
endif()
message(STATUS "Setting USD_LOCATION to '${USD_LOCATION}'")
message(STATUS "Setting DEVKIT_LOCATION to '$ENV{DEVKIT_LOCATION}'")
if(NOT DEFINED ENV{DEVKIT_LOCATION})
message(FATAL_ERROR "$DEVKIT_LOCATION is not set. Please set it as an env var.")
endif()
find_package(Qt5 REQUIRED COMPONENTS Widgets Core)
qt5_add_resources(RESOURCES static/resources.qrc)
# export compile commands for linter
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# silence warnings
add_compile_options(
# maya devkit warnings
-Wno-deprecated
-Wno-redundant-move
-Wno-missing-field-initializers
-Wno-deprecated-copy
-Wno-cast-user-defined
# silence tbb usd compile issue
-Wno-changes-meaning
)
# setup core
add_library(maya_usd_export_core STATIC
src/export/PrimWriter.cpp
src/export/ExportItem.cpp
)
set_target_properties(maya_usd_export_core PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_include_directories(maya_usd_export_core
PUBLIC "${USD_LOCATION}/include"
PRIVATE "$ENV{DEVKIT_LOCATION}/include"
PUBLIC include
PRIVATE src
)
target_link_libraries(maya_usd_export_core
"${USD_LOCATION}/lib/libusd_usd.so"
"${USD_LOCATION}/lib/libusd_usdGeom.so"
# "${USD_LOCATION}/lib/libusd_vt.so"
)
# setup plugin
# load devkit
set(interface_sources
src/interface/main_export_dialog.cpp
src/interface/main_export_dialog.h
src/interface/controllers/MainExportDialogController.cpp
src/interface/controllers/SelectionOptionsController.cpp
src/interface/widgets/CollapsibleContainer.h
src/interface/widgets/CollapsibleContainer.cpp
src/interface/widgets/GeneralOptions.h
src/interface/widgets/GeneralOptions.cpp
src/interface/widgets/SelectionOptions.h
src/interface/widgets/SelectionOptions.cpp
src/interface/widgets/AnimationOptions.h
src/interface/widgets/AnimationOptions.cpp
src/interface/widgets/SelectionParameters.h
src/interface/widgets/SelectionParameters.cpp
src/interface/models/DAGSelectionModel.cpp
src/interface/models/DAGSelectionModel.h
)
set(SOURCE_FILES
src/plugin_entry.cpp
${interface_sources}
${RESOURCES}
)
include($ENV{DEVKIT_LOCATION}/cmake/pluginEntry.cmake)
set(
LIBRARIES
OpenMaya
Foundation
# Qt5Core
# Qt5Widgets
)
build_plugin()
target_link_libraries(${PROJECT_NAME}
maya_usd_export_core
# "$ENV{DEVKIT_LOCATION}/devkit/lib/libQt5Core.so"
"${USD_LOCATION}/lib/libusd_usd.so"
)
target_include_directories(${PROJECT_NAME}
# BEFORE becasue maya's tbb is broken so it uses this one
BEFORE PRIVATE "${USD_LOCATION}/include"
)
add_definitions(-std=c++17)
# ----
# build interface
# ----
# set(CMAKE_PREFIX_PATH "$ENV{DEVKIT_LOCATION}/cmake/qt_5.15.2")
# set(CMAKE_PREFIX_PATH "$ENV{DEVKIT_LOCATION}/devkit")
message(STATUS "QT DIR: ${Qt5_DIR}")
target_include_directories(${PROJECT_NAME}
PRIVATE "$ENV{DEVKIT_LOCATION}/include"
PRIVATE src
)
# ----
# build tests
# ----
if(BUILD_TESTS)
message(STATUS "BUILDING TESTS")
# try to find catch2 for testing
find_package(Catch2 3 QUIET)
# download if not found
if(NOT Catch2_FOUND)
message(STATUS "Catch2 not found, using FetchContent to download it")
include(FetchContent)
FetchContent_Declare(
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v3.8.1
)
FetchContent_MakeAvailable(Catch2)
endif()
# source tests
add_executable(tests tests/unit-tests/test-main.cpp)
# link to core lib
set(LIBRARY_DIRS $ENV{DEVKIT_LOCATION})
find_library(OpenMaya_PATH
NAMES OpenMaya
PATHS ${LIBRARY_DIRS}
NO_DEFAULT_PATH
)
find_library(Foundation_PATH
NAMES Foundation
PATHS ${LIBRARY_DIRS}
NO_DEFAULT_PATH
)
message(STATUS "OPEN MAYA PATH: ${OpenMaya_PATH}")
message(STATUS "OPEN FOUNDATION PATH: ${Foundation_PATH}")
target_link_libraries(tests PRIVATE
Catch2::Catch2WithMain
maya_usd_export_core
# ${OpenMaya_PATH}
# ${Foundation_PATH}
)
target_include_directories(tests BEFORE
PUBLIC "${USD_LOCATION}/include"
)
# target_include_directories(tests
# PUBLIC "$ENV{DEVKIT_LOCATION}/include"
# )
# ctest
include(CTest)
include(Catch)
catch_discover_tests(tests)
endif()