forked from Exocortex/ExocortexCrate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ExocortexCMakeShared.txt
353 lines (275 loc) · 11.9 KB
/
ExocortexCMakeShared.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
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
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
function(setup_os_name)
if( UNIX )
set(OS_NAME "linux" PARENT_SCOPE )
elseif( WIN32 )
set(OS_NAME "windows" PARENT_SCOPE )
else()
message(FATAL_ERROR "Can not determine OS_NAME")
endif()
endfunction()
function(setup_cpu_name)
if( CMAKE_SIZEOF_VOID_P MATCHES "8" )
set(CPU_NAME "x64" PARENT_SCOPE )
elseif( CMAKE_SIZEOF_VOID_P MATCHES "4" )
set(CPU_NAME "x86" PARENT_SCOPE )
else()
message(FATAL_ERROR "Can not determine CPU_NAME, CMAKE_SIZEOF_VOID_P is: ${CMAKE_SIZEOF_VOID_P}")
endif()
endfunction()
function(setup_precompiled_header LocalSourceDir)
if (MSVC)
set( LOCAL_SOURCE_DIR ${LocalSourceDir} )
list( REMOVE_ITEM ARGN "${LOCAL_SOURCE_DIR}/stdafx.cpp" )
list( REMOVE_ITEM ARGN "${LOCAL_SOURCE_DIR}/stdafx.h" )
foreach( src_file ${ARGN} )
set_source_files_properties(
${src_file}
PROPERTIES
COMPILE_FLAGS "/Yustdafx.h"
)
endforeach()
set_source_files_properties("${LOCAL_SOURCE_DIR}/stdafx.cpp"
PROPERTIES
COMPILE_FLAGS "/Ycstdafx.h"
)
endif()
endfunction()
function(setup_exocortex_output_postfix)
SET( EXOCORTEX_OUTPUT_POSTFIX "" )
if( CMAKE_SIZEOF_VOID_P MATCHES "8" )
SET( EXOCORTEX_OUTPUT_POSTFIX ${EXOCORTEX_OUTPUT_POSTFIX}/x64 )
endif( CMAKE_SIZEOF_VOID_P MATCHES "8" )
if( CMAKE_SIZEOF_VOID_P MATCHES "4" )
SET( EXOCORTEX_OUTPUT_POSTFIX ${EXOCORTEX_OUTPUT_POSTFIX}/x86 )
endif( CMAKE_SIZEOF_VOID_P MATCHES "4" )
if( UNIX )
SET( EXOCORTEX_OUTPUT_POSTFIX ${EXOCORTEX_OUTPUT_POSTFIX}/linux )
endif( UNIX )
if( WIN32 )
SET( EXOCORTEX_OUTPUT_POSTFIX ${EXOCORTEX_OUTPUT_POSTFIX}/windows )
endif( WIN32 )
SET( EXOCORTEX_OUTPUT_POSTFIX ${EXOCORTEX_OUTPUT_POSTFIX} PARENT_SCOPE )
# MESSAGE( ${EXOCORTEX_OUTPUT_POSTFIX} )
endfunction(setup_exocortex_output_postfix)
function(setup_softimage_output_postfix)
if( WIN32 )
if( CMAKE_SIZEOF_VOID_P MATCHES "8" )
SET( SOFTIMAGE_OUTPUT_POSTFIX "/nt-x86-64" )
endif( CMAKE_SIZEOF_VOID_P MATCHES "8" )
if( CMAKE_SIZEOF_VOID_P MATCHES "4" )
SET( SOFTIMAGE_OUTPUT_POSTFIX "/nt-x86" )
endif( CMAKE_SIZEOF_VOID_P MATCHES "4" )
endif( WIN32 )
if( UNIX )
if( CMAKE_SIZEOF_VOID_P MATCHES "8" )
SET( SOFTIMAGE_OUTPUT_POSTFIX "/linux-x86-64" )
endif( CMAKE_SIZEOF_VOID_P MATCHES "8" )
endif( UNIX )
SET( SOFTIMAGE_OUTPUT_POSTFIX ${SOFTIMAGE_OUTPUT_POSTFIX} PARENT_SCOPE )
# MESSAGE( ${SOFTIMAGE_OUTPUT_POSTFIX} )
endfunction(setup_softimage_output_postfix)
function(setup_boost)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
#set(Boost_DEBUG ON )
#set(Boost_DETAILED_FAILURE_MSG ON )
set(Boost_USE_STATIC_RUNTIME OFF)
SET( Boost_NO_SYSTEM_PATHS true )
find_package( Boost 1.43.0 COMPONENTS date_time filesystem system program_options regex thread iostreams zlib REQUIRED )
include_directories( ${Boost_INCLUDE_DIRS} )
link_directories( ${Boost_LIBRARY_DIRS} )
MESSAGE("---- BOOST INCLUDE DIRS...")
MESSAGE( ${Boost_INCLUDE_DIRS} )
MESSAGE( ${Boost_LIBRARY_DIRS} )
endfunction(setup_boost)
function(setup_compiler_settings)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
endfunction(setup_compiler_settings)
function(create_source_group sourceGroupName relativeSourcePath )
FOREACH(currentSourceFile ${ARGN})
FILE(RELATIVE_PATH folder ${relativeSourcePath} ${currentSourceFile})
get_filename_component(filename ${folder} NAME)
string(REPLACE ${filename} "" folder ${folder})
if(NOT folder STREQUAL "")
string(REGEX REPLACE "/+$" "" folderlast ${folder})
string(REPLACE "/" "\\" folderlast ${folderlast})
SOURCE_GROUP("${sourceGroupName}\\${folderlast}" FILES ${currentSourceFile})
endif(NOT folder STREQUAL "")
ENDFOREACH(currentSourceFile)
endfunction(create_source_group)
function(setup_project_sources_only Sources )
create_source_group("Source Files" "${CMAKE_CURRENT_SOURCE_DIR}/src" ${Sources})
endfunction(setup_project_sources_only)
function(setup_project Sources Includes)
create_source_group("Source Files" "${CMAKE_CURRENT_SOURCE_DIR}/src" ${Sources})
create_source_group("Header Files" "${CMAKE_CURRENT_SOURCE_DIR}/include" ${Includes})
endfunction(setup_project)
function(setup_tbb)
if( WIN32 )
if( CMAKE_SIZEOF_VOID_P MATCHES "8" )
SET( TBB_PLATFORM_POSTFIX "em64t/vc9" )
endif( CMAKE_SIZEOF_VOID_P MATCHES "8" )
if( CMAKE_SIZEOF_VOID_P MATCHES "4" )
SET( TBB_PLATFORM_POSTFIX "ia32/vc9" )
endif( CMAKE_SIZEOF_VOID_P MATCHES "4" )
endif( WIN32 )
if( UNIX )
if( CMAKE_SIZEOF_VOID_P MATCHES "8" )
SET( TBB_PLATFORM_POSTFIX "linux-x86-64" )
endif( CMAKE_SIZEOF_VOID_P MATCHES "8" )
endif( UNIX )
SET( TBB_INCLUDE_DIR ${TBB_BASE_DIR}/include PARENT_SCOPE )
SET( TBB_LIBRARY_DIR ${TBB_BASE_DIR}/${TBB_PLATFORM_POSTFIX}/lib )
SET( TBB_LIBRARIES "${TBB_LIBRARY_DIR}/tbb.lib" "${TBB_LIBRARY_DIR}/tbb_debug.lib" "${TBB_LIBRARY_DIR}/tbbmalloc.lib" "${TBB_LIBRARY_DIR}/tbbmalloc_debug.lib" PARENT_SCOPE )
SET( TBB_DEPENDENCIES_DIR "${TBB_BASE_DIR}/${TBB_PLATFORM_POSTFIX}/bin" )
SET( TBB_DEPENDENCIES "${TBB_DEPENDENCIES_DIR}/tbb.dll" "${TBB_DEPENDENCIES_DIR}/tbb_debug.dll" "${TBB_DEPENDENCIES_DIR}/tbbmalloc.dll" "${TBB_DEPENDENCIES_DIR}/tbbmalloc_debug.dll" PARENT_SCOPE )
endfunction(setup_tbb)
function(setup_softimage)
if( WIN32 )
if( CMAKE_SIZEOF_VOID_P MATCHES "8" )
SET( SOFTIMAGE_OUTPUT_POSTFIX "nt-x86-64" )
endif( CMAKE_SIZEOF_VOID_P MATCHES "8" )
if( CMAKE_SIZEOF_VOID_P MATCHES "4" )
SET( SOFTIMAGE_OUTPUT_POSTFIX "nt-x86" )
endif( CMAKE_SIZEOF_VOID_P MATCHES "4" )
endif( WIN32 )
if( UNIX )
if( CMAKE_SIZEOF_VOID_P MATCHES "8" )
SET( SOFTIMAGE_OUTPUT_POSTFIX "linux-x86-64" )
endif( CMAKE_SIZEOF_VOID_P MATCHES "8" )
endif( UNIX )
SET( Softimage_INCLUDE_DIR ${Softimage_BASE_DIR}/include PARENT_SCOPE )
SET( Softimage_LIBRARY_DIR ${Softimage_BASE_DIR}/lib/${SOFTIMAGE_OUTPUT_POSTFIX} )
SET( Softimage_LIBRARIES "${Softimage_LIBRARY_DIR}/sicoresdk.lib" "${Softimage_LIBRARY_DIR}/sicppsdk.lib" PARENT_SCOPE )
endfunction(setup_softimage)
function(setup_maya)
if( WIN32 )
if( CMAKE_SIZEOF_VOID_P MATCHES "8" )
SET( Maya_OUTPUT_POSTFIX "nt-x86-64" )
endif( CMAKE_SIZEOF_VOID_P MATCHES "8" )
if( CMAKE_SIZEOF_VOID_P MATCHES "4" )
SET( Maya_OUTPUT_POSTFIX "nt-x86" )
endif( CMAKE_SIZEOF_VOID_P MATCHES "4" )
endif( WIN32 )
if( UNIX )
if( CMAKE_SIZEOF_VOID_P MATCHES "8" )
SET( Maya_OUTPUT_POSTFIX "linux-x86-64" )
endif( CMAKE_SIZEOF_VOID_P MATCHES "8" )
endif( UNIX )
SET( Maya_INCLUDE_DIR ${Maya_BASE_DIR}/include PARENT_SCOPE )
# SET( Maya_LIBRARY_DIR ${Maya_BASE_DIR}/lib/${Maya_OUTPUT_POSTFIX} )
# SET( Maya_LIBRARIES "${Maya_LIBRARY_DIR}/sicoresdk.lib" "${Maya_LIBRARY_DIR}/sicppsdk.lib" PARENT_SCOPE )
SET( Maya_LIBRARY_DIR ${Maya_BASE_DIR}/lib/${Maya_OUTPUT_POSTFIX} )
SET( Maya_LIBRARIES "${Maya_LIBRARY_DIR}/Foundation.lib" "${Maya_LIBRARY_DIR}/OpenMaya.lib" "${Maya_LIBRARY_DIR}/OpenMayaAnim.lib" "${Maya_LIBRARY_DIR}/OpenMayaRender.lib" "${Maya_LIBRARY_DIR}/OpenMayaFX.lib" "${Maya_LIBRARY_DIR}/OpenMayaUI.lib" PARENT_SCOPE )
endfunction(setup_maya)
function(deploy_maya OutputName WorkgroupName )
SET( Maya_PLUGINS_DIR "C:/Program Files/Autodesk/Maya2011/bin/plug-ins" )
SET( Maya_BIN_DIR "C:/Program Files/Autodesk/Maya2011/bin/plug-ins" )
GET_TARGET_PROPERTY( OUTPUT_LOCATION ${OutputName} LOCATION )
ADD_CUSTOM_COMMAND(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${OUTPUT_LOCATION} ${Maya_PLUGINS_DIR}
)
endfunction(deploy_maya)
function(get_softimage_workgroup WorkgroupName)
if( WIN32 )
if( CMAKE_SIZEOF_VOID_P MATCHES "8" )
set( SOFTIMAGE_OUTPUT_POSTFIX "/nt-x86-64" )
endif( CMAKE_SIZEOF_VOID_P MATCHES "8" )
if( CMAKE_SIZEOF_VOID_P MATCHES "4" )
set( SOFTIMAGE_OUTPUT_POSTFIX "/nt-x86" )
endif( CMAKE_SIZEOF_VOID_P MATCHES "4" )
endif( WIN32 )
if( UNIX )
if( CMAKE_SIZEOF_VOID_P MATCHES "8" )
set( SOFTIMAGE_OUTPUT_POSTFIX "/linux-x86-64" )
endif( CMAKE_SIZEOF_VOID_P MATCHES "8" )
endif( UNIX )
set( Softimage_WORKGROUP_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Workgroup/Addons/${WorkgroupName}/Application/Plugins/bin${SOFTIMAGE_OUTPUT_POSTFIX} PARENT_SCOPE )
endfunction(get_softimage_workgroup)
function(deploy_softimage OutputName WorkgroupName )
get_softimage_workgroup( ${WorkgroupName} )
get_target_property( OUTPUT_LOCATION ${OutputName} LOCATION )
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${Softimage_WORKGROUP_DIR}
COMMAND ${CMAKE_COMMAND} -E copy ${OUTPUT_LOCATION} ${Softimage_WORKGROUP_DIR}
)
#message( "ARGN: ${ARGN}" )
get_filename_component( OUTPUT_DIR "${OUTPUT_LOCATION}" PATH )
#message( "OUTPUT_DIR: ${OUTPUT_DIR}" )
foreach(dependencyLocation ${ARGN})
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${dependencyLocation} ${Softimage_WORKGROUP_DIR}
)
endforeach(dependencyLocation)
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E remove -f "${Softimage_WORKGROUP_DIR}/${WorkgroupName}.dll" )
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E remove -f "${Softimage_WORKGROUP_DIR}/${WorkgroupName}.so" )
endfunction(deploy_softimage)
function(remove_obsolete_softimage OutputName WorkgroupName )
get_softimage_workgroup( ${WorkgroupName} )
GET_TARGET_PROPERTY( OUTPUT_LOCATION ${OutputName} LOCATION )
GET_FILENAME_COMPONENT( OUTPUT_DIR "${OUTPUT_LOCATION}" PATH )
#MESSAGE( "OUTPUT_DIR: ${OUTPUT_DIR}" )
FOREACH(dependencyLocation ${ARGN})
ADD_CUSTOM_COMMAND(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E remove -f ${dependencyLocation} ${Softimage_WORKGROUP_DIR}
)
ENDFOREACH(dependencyLocation)
endfunction(remove_obsolete_softimage)
function(deploy_standard OutputName )
GET_TARGET_PROPERTY( OUTPUT_LOCATION ${OutputName} LOCATION )
GET_FILENAME_COMPONENT( OUTPUT_DIR "${OUTPUT_LOCATION}" PATH )
#MESSAGE( "ARGN: ${ARGN}" )
FOREACH(dependencyLocation ${ARGN})
ADD_CUSTOM_COMMAND(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${dependencyLocation} ${OUTPUT_DIR}
)
ENDFOREACH(dependencyLocation)
endfunction(deploy_standard)
function(copy_files GLOBPAT OutputName)
GET_TARGET_PROPERTY( OUTPUT_LOCATION ${OutputName} LOCATION )
GET_FILENAME_COMPONENT( OUTPUT_DIR "${OUTPUT_LOCATION}" PATH )
GET_FILENAME_COMPONENT( OUTPUT_DIR "${OUTPUT_DIR}" PATH )
file(GLOB COPY_FILES
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${GLOBPAT} )
#add_custom_target(copy ALL
# COMMENT "Copying files: ${GLOBPAT}")
foreach(FILENAME ${COPY_FILES})
if(NOT IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${FILENAME}" )
set(SRC "${CMAKE_CURRENT_SOURCE_DIR}/${FILENAME}")
set(DST "${OUTPUT_DIR}/${FILENAME}")
add_custom_command(
TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${SRC} ${DST}
)
endif()
endforeach(FILENAME)
endfunction(copy_files)
function( remove_dir Directory )
add_custom_command(
TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E remove_directory ${Directory} )
endfunction()
function( copy_file_to_file SourceFileName DestinationFileName )
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${SourceFileName} ${DestinationFileName} )
endfunction()
function( copy_file_to_directory SourceFileName DestinationDirectory )
get_filename_component( FileName "${SourceFileName}" NAME )
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${SourceFileName} ${DestinationDirectory}/${FileName} )
endfunction()
function( copy_directory SourceDir DestinationDirectory )
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${DestinationDirectory})
file( GLOB SourceFileNames ${SourceDir}/* )
foreach( SourceFileName ${SourceFileNames} )
get_filename_component( FileName "${SourceFileName}" NAME )
if( NOT IS_DIRECTORY ${SourceFileName} )
set(DestinationFileName "${DestinationDirectory}/${FileName}")
copy_file_to_file( ${SourceFileName} ${DestinationFileName} )
else()
copy_directory( ${SourceFileName} "${DestinationDirectory}/${FileName}" )
endif()
endforeach()
endfunction()