-
Notifications
You must be signed in to change notification settings - Fork 7
/
CMakeLists.txt
104 lines (82 loc) · 3.79 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
cmake_minimum_required(VERSION 2.6)
project(Sampler)
set ( MAYA_PLUGIN_NAME "Sampler" )
# Platform specific definitions
if(WIN32)
if(MSVC)
# To enable /MP, parallel build on MSVC
option(WIN32_USE_MP "Set to OFF to diable /MP." ON)
MARK_AS_ADVANCED(WIN32_USE_MP)
if(WIN32_USE_MP)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
endif(WIN32_USE_MP)
# Other MSVC compilation flags
add_definitions(-D_SCL_SECURE_NO_WARNINGS)
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
add_definitions(-D NOMINMAX) # prevent windef.h min/max macros from interfering with stl's
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
endif(MSVC)
endif (WIN32)
# Set the Maya version and architecture (default values)
set(MAYA_VERSION 2011 CACHE STRING "Maya Version")
set(MAYA_ARCH x64 CACHE STRING "HW Architecture")
if ( "${MAYA_ARCH}" STREQUAL "x64")
set(x64_BUILD true)
endif()
if(WIN32)
set( MAYA_USER_DIR $ENV{USERPROFILE}/Documents/maya CACHE PATH "Maya user home directory" )
set( MAYA_SDK_DEFINITIONS "_AFXDLL;_MBCS;NT_PLUGIN;REQUIRE_IOSTREAM" )
if(x64_BUILD)
set( MAYA_ROOT $ENV{PROGRAMW6432}/Autodesk/Maya${MAYA_VERSION} CACHE PATH "Maya installation directory" )
else()
SET(PROGRAMFILESx86 "ProgramFiles(x86)")
SET(PF $ENV{${PROGRAMFILESx86}})
message("PF " ${PF})
set( MAYA_ROOT ${PF}/Autodesk/Maya${MAYA_VERSION} CACHE PATH "Maya installation directory" )
endif()
else()
set( MAYA_USER_DIR $ENV{HOME}/maya CACHE PATH "Maya user home directory" )
set( MAYA_ROOT /usr/autodesk/maya${MAYA_VERSION}-${MAYA_ARCH} )
endif()
find_package(OpenGL REQUIRED)
set( GLEW_DIR "C:/glew-1.5.8" CACHE STRING "path to glew installation folder" )
set( GLEW_INCLUDE_DIR ${GLEW_DIR}/include )
set( GLEW_LIBRARY_DIR ${GLEW_DIR}/lib )
set( MAYA_HEADERS_DIR ${MAYA_ROOT}/include )
set( MAYA_LIBRARY_DIR ${MAYA_ROOT}/lib )
set ( LOCAL_WARNING_FLAGS /W3 )
set ( LOCAL_RTTI_FLAGS /GR )
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../bin/${MAYA_ARCH})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../bin/${MAYA_ARCH})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../bin/${MAYA_ARCH})
# add base to include directories
include_directories ( ${PUBLIC_INCLUDE_DIRS} ${MAYA_HEADERS_DIR} ${OPENGL_INCLUDE_DIR} ${GLEW_INCLUDE_DIR})
link_directories ( ${PUBLIC_LIBRARY_DIRS} ${MAYA_LIBRARY_DIR} ${GLEW_LIBRARY_DIR})
set( OPENGL_LIB opengl32.lib glu32.lib)
set( MAYA_DEFINITIONS "_AFXDLL,_MBCS,NT_PLUGIN,REQUIRE_IOSTREAM" )
set( MAYASDK_LIBRARIES "Foundation.lib" "OpenMaya.lib" "OpenMayaUI.lib" "OpenMayaAnim.lib" "OpenMayaFX.lib" "OpenMayaRender.lib" )
# 64-bit compilation options
if (x64_BUILD)
message( "64-bit build")
set( MAYA_DEFINITIONS ${MAYA_DEFINITIONS},Bits64_ )
set( GLEW_LIB glew64.lib )
if(UNIX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64")
endif(UNIX)
else()
message( "32-bit build")
set( GLEW_LIB glew32.lib )
endif()
# print search paths and options
message("Looking for Maya on " ${MAYA_ROOT})
message("Looking for GLEW on " ${GLEW_DIR})
message("Compiling for Maya" ${MAYA_VERSION}-${MAYA_ARCH} )
# specify app sources
file(GLOB_RECURSE SOURCE_FILES src/*.c src/*.cpp src/*.h src/*.inl src/*.hpp src/*.glsl src/*.ui)
add_library( ${MAYA_PLUGIN_NAME} SHARED ${SOURCE_FILES} )
target_link_libraries( ${MAYA_PLUGIN_NAME} ${MAYASDK_LIBRARIES} ${OPENGL_LIB} ${GLEW_LIB} ${GLUT_LIBRARIES})
set_target_properties( ${MAYA_PLUGIN_NAME} PROPERTIES COMPILE_DEFINITIONS ${MAYA_DEFINITIONS} )
set_target_properties( ${MAYA_PLUGIN_NAME} PROPERTIES OUTPUT_NAME ${MAYA_PLUGIN_NAME} )
set_target_properties( ${MAYA_PLUGIN_NAME} PROPERTIES SUFFIX ".mll" )
set_target_properties( ${MAYA_PLUGIN_NAME} PROPERTIES CLEAN_DIRECT_OUTPUT 1 )
set_target_properties( ${MAYA_PLUGIN_NAME} PROPERTIES LINK_FLAGS "/export:initializePlugin /export:uninitializePlugin" )