-
Notifications
You must be signed in to change notification settings - Fork 59
/
CMakeLists.txt
230 lines (200 loc) · 6.68 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
cmake_minimum_required( VERSION 3.1 )
project( Maya )
set( MAYA_VERSION 2014 CACHE STRING "" )
set( MAYA_SOURCE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
set( MAYA_SCRIPT_DIRECTORY "${MAYA_SOURCE_DIRECTORY}/scripts")
set( MAYA_ICON_DIRECTORY "${MAYA_SOURCE_DIRECTORY}/icons")
include( ./cmake/PluginFiles.cmake )
########################################
# Module structure
########################################
set( install_module_dir "maya${MAYA_VERSION}" )
set( install_plug_ins_dir "${install_module_dir}/plug-ins" )
set( install_module_absolute_dir "${CMAKE_INSTALL_PREFIX}/${install_module_dir}" )
########################################
# Find packages
########################################
set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules" )
set(
maya_libraries
OpenMaya
OpenMayaAnim
OpenMayaFX
Foundation
)
find_package( Maya ${MAYA_VERSION} EXACT REQUIRED ${maya_libraries} )
find_package( HoudiniEngine REQUIRED )
########################################
# Relative paths
########################################
file(
RELATIVE_PATH
install_plug_ins_dir_to_houdiniengine_lib_dir
"${CMAKE_INSTALL_PREFIX}/${install_plug_ins_dir}"
"${HoudiniEngine_LIBRARY_DIR}"
)
file(
RELATIVE_PATH
install_module_dir_to_houdiniengine_bin_dir
"${install_module_absolute_dir}"
"${HoudiniEngine_BINARY_DIR}"
)
########################################
# plugin
########################################
add_library( plugin SHARED ${MAYA_PLUGIN_SOURCES} )
if ( ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" )
set( plugin_suffix ".so" )
elseif ( ${CMAKE_SYSTEM_NAME} STREQUAL "Windows" )
set( plugin_suffix ".mll" )
elseif ( ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" )
set( plugin_suffix ".bundle" )
endif ()
set_target_properties(
plugin
PROPERTIES
OUTPUT_NAME houdiniEngine
PREFIX ""
SUFFIX "${plugin_suffix}"
)
set_target_properties(
plugin
PROPERTIES
CXX_STANDARD 11
)
# Compile definitions
set( compile_definitions )
if ( ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" )
elseif ( ${CMAKE_SYSTEM_NAME} STREQUAL "Windows" )
list(
APPEND compile_definitions
_CRT_NONSTDC_NO_WARNINGS
_CRT_SECURE_NO_WARNINGS
_SCL_SECURE_NO_WARNINGS
)
elseif ( ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" )
endif ()
target_compile_definitions( plugin PRIVATE ${compile_definitions} )
# Compile options
if ( ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" )
set(
compile_options
-Wall
-O2
)
elseif ( ${CMAKE_SYSTEM_NAME} STREQUAL "Windows" )
set(
compile_options
-W4
# Enabled warnings
-w14101 # unreferenced local variable
-w14996 # Deprecation usage
# Warnings treated as errors
-we4265 # 'class' has virtual functions but destructor is not virtual
-we4700 # uninitialized local variable used
-we4715 # not all control paths return a value
-we4717 # recursive on all control paths, function will cause runtime stack overflow
-we4263 # member func does not override any base class virt member func
-we4266 # no override for virt member func from base 'type'; func is hidden
-we4390 # empty controlled statement found; is this the intent?
-we4407 # cast between different pointer to member representations, compiler may generate incorrect code
# Disabled warnings
-wd4100 # unreferenced formal parameter
-wd4244 # conversion of floating point type possible loss of data
-wd4267 # conversion of integer type possible loss of data
-wd4389 # signed/unsigned mismatch
-wd4458 # declaration of 'identifier' hides class member
/O2
/DEBUG
/Zi
/DYNAMICBASE:NO
/EHsc
)
elseif ( ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" )
set(
compile_options
-Wall
-O2
)
endif ()
target_compile_options( plugin PRIVATE ${compile_options} )
# Maya libraries
target_link_libraries( plugin ${maya_libraries} )
# Houdini Engine libraries
target_link_libraries( plugin HoudiniEngine )
# Setup rpath
if ( ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" )
set_target_properties(
plugin
PROPERTIES
INSTALL_RPATH "$ORIGIN/${install_plug_ins_dir_to_houdiniengine_lib_dir};$ORIGIN/../../dsolib"
)
elseif ( ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" )
set_target_properties(
plugin
PROPERTIES
MACOSX_RPATH TRUE
INSTALL_RPATH "@loader_path/${install_plug_ins_dir_to_houdiniengine_lib_dir};@loader_path/../../Frameworks/Houdini.framework/Versions/Current/Libraries"
)
endif ()
set_target_properties(
plugin
PROPERTIES
POSITION_INDEPENDENT_CODE ON
)
########################################
# Module files
########################################
set( MODULE_DESCRIPTION_ENVIRONMENTS )
set( MODULE_DESCRIPTION_ABSOLUTE_ENVIRONMENTS )
# Set the PATH variable for executables and dynamic library.
set(
MODULE_DESCRIPTION_ENVIRONMENTS
"${MODULE_DESCRIPTION_ENVIRONMENTS}PATH +:= ${install_module_dir_to_houdiniengine_bin_dir}\n"
)
set(
MODULE_DESCRIPTION_ABSOLUTE_ENVIRONMENTS
"${MODULE_DESCRIPTION_ABSOLUTE_ENVIRONMENTS}PATH += ${install_module_absolute_dir}/${install_module_dir_to_houdiniengine_bin_dir}\n"
)
# HOUDINI_DSO_EXCLUDE_PATTERN
# Block out Houdini plugins that would load Houdini's UI libraries.
set(
houdini_dso_exclude_pattern
"HOUDINI_DSO_EXCLUDE_PATTERN={CHOP_Mouse3D,COP2_GPULighting,COP2_GPUFog,COP2_GPUEnvironment,COP2_GPUZComposite,COP2_EnableGPU,SHOP_OGL,SOP_VDBUI,VEX_OpRender,USD_Ops}*"
)
set(
MODULE_DESCRIPTION_ENVIRONMENTS
"${MODULE_DESCRIPTION_ENVIRONMENTS}${houdini_dso_exclude_pattern}\n"
)
set(
MODULE_DESCRIPTION_ABSOLUTE_ENVIRONMENTS
"${MODULE_DESCRIPTION_ABSOLUTE_ENVIRONMENTS}${houdini_dso_exclude_pattern}\n"
)
# Generate module files
configure_file( module_description.in "houdiniEngine-maya${MAYA_VERSION}" )
configure_file( module_description_absolute.in "${install_module_dir}/houdiniEngine-maya${MAYA_VERSION}" )
########################################
# Install
########################################
install(
TARGETS plugin
DESTINATION "${install_plug_ins_dir}"
)
install(
DIRECTORY scripts
DESTINATION "${install_module_dir}"
PATTERN ".svn" EXCLUDE
)
install(
DIRECTORY icons
DESTINATION "${install_module_dir}"
PATTERN ".svn" EXCLUDE
)
install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/houdiniEngine-maya${MAYA_VERSION}"
DESTINATION "."
)
install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/${install_module_dir}/houdiniEngine-maya${MAYA_VERSION}"
DESTINATION "${install_module_dir}"
)