-
Notifications
You must be signed in to change notification settings - Fork 21
/
CMakeLists_template.txt
87 lines (74 loc) · 2.92 KB
/
CMakeLists_template.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
cmake_minimum_required(VERSION 2.8)
project(sampleProject)
set(SOURCE_FILES
)
# https://www.guyrutenberg.com/2014/01/05/enabling-c11-c0x-in-cmake/
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if (NOT WIN32)
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -mtune=native -march=native")
endif()
if (COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif(COMPILER_SUPPORTS_CXX0X)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else()
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()
find_package(OpenMP)
if (OPENMP_FOUND)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
endif()
set(MAYA_VERSION 2018 CACHE STRING "Maya version")
set(CMAKE_BUILD_TYPE Release CACHE STRING "Default build type")
if (WIN32)
set(INCLUDE_DIR "C:/Program Files/Autodesk/Maya${MAYA_VERSION}/include")
set(LIBRARY_DIR "C:/Program Files/Autodesk/Maya${MAYA_VERSION}/lib")
set(MAYA_COMPILE_DEFINITIONS "REQUIRE_IOSTREAM;_BOOL;NT_PLUGIN")
set(MAYA_PLUGIN_EXTENSION ".mll")
set(MAYA_TARGET_TYPE RUNTIME)
set(INSTALL_DIR ../plug-ins/win_${MAYA_VERSION})
elseif (APPLE)
set(INCLUDE_DIR "/Applications/Autodesk/maya${MAYA_VERSION}/devkit/include")
set(LIBRARY_DIR "/Applications/Autodesk/maya${MAYA_VERSION}/Maya.app/Contents/MacOS")
set(MAYA_COMPILE_DEFINITIONS "REQUIRE_IOSTREAM;_BOOL;OSMac_")
set(MAYA_PLUGIN_EXTENSION ".bundle")
set(MAYA_TARGET_TYPE LIBRARY)
set(CMAKE_MACOSX_RPATH ON)
set(INSTALL_DIR ../plug-ins/macOS_${MAYA_VERSION})
else ()
set(INCLUDE_DIR "")
set(LIBRARY_DIR "")
set(MAYA_COMPILE_DEFINITIONS "REQUIRE_IOSTREAM;_BOOL;LINUX")
set(MAYA_PLUGIN_EXTENSION ".so")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
set(MAYA_TARGET_TYPE LIBRARY)
set(INSTALL_DIR ../plug-ins/linux_${MAYA_VERSION})
endif()
include_directories(${INCLUDE_DIR})
link_directories(${LIBRARY_DIR})
add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES})
target_link_libraries(${PROJECT_NAME}
OpenMaya
OpenMayaAnim
OpenMayaFX
OpenMayaRender
OpenMayaUI
Foundation
)
if (WIN32)
set_target_properties(${PROJECT_NAME} PROPERTIES
LINK_FLAGS "/export:initializePlugin /export:uninitializePlugin"
)
endif()
set_target_properties(${PROJECT_NAME} PROPERTIES
COMPILE_DEFINITIONS "${MAYA_COMPILE_DEFINITIONS}"
PREFIX ""
SUFFIX ${MAYA_PLUGIN_EXTENSION}
)
install(TARGETS ${PROJECT_NAME} ${MAYA_TARGET_TYPE} DESTINATION ${INSTALL_DIR})
set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_BINARY_DIR})