Maya with CMake

CMake File

cmake_minimum_required(VERSION 2.6)
project(animagi)

set(MAYA_VERSION 2017 CACHE STRING "Maya Version Number")
set(SOURCE_FILES
        "src/pluginMain.cpp"
        )

set(CMAKE_MACOSX_RPATH 1)
FIND_PACKAGE(OpenGL REQUIRED)

set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/bin)

# OS Specific environment setup
SET(CUSTOM_DEFINITIONS "REQUIRE_IOSTREAM;_BOOL")
SET(MAYA_INSTALL_BASE_SUFFIX "")
SET(MAYA_INC_SUFFIX "include")
SET(MAYA_LIB_SUFFIX "lib")
IF(WIN32)
    # Windows
    SET(MAYA_INSTALL_BASE_DEFAULT "C:/Program Files/Autodesk")
    SET(CUSTOM_DEFINITIONS "${CUSTOM_DEFINITIONS};NT_PLUGIN")
ELSEIF(APPLE)
    # Apple
    SET(MAYA_INSTALL_BASE_DEFAULT "/Applications/Autodesk")
    SET(MAYA_INC_SUFFIX "devkit/include")
    SET(MAYA_LIB_SUFFIX "Maya.app/Contents/MacOS")
    SET(CUSTOM_DEFINITIONS "${CUSTOM_DEFINITIONS};OSMac_")
ELSE(WIN32)
    # Linux
    SET(MAYA_INSTALL_BASE_DEFAULT "/usr/autodesk")
    SET(MAYA_INSTALL_BASE_SUFFIX "-x64")
ENDIF(WIN32)

SET(MAYA_INSTALL_BASE_PATH ${MAYA_INSTALL_BASE_DEFAULT} CACHE STRING
        "Path containing all your maya installations, like /usr/autodesk or /Applications/Autodesk/")

SET(LIBRARIES ${LIBRARIES} "Foundation" "OpenMaya" "OpenMayaAnim" "OpenMayaUI" "OpenMayaRender" ${OPENGL_LIBRARIES})

SET(_MAYA_LOCATION ${MAYA_INSTALL_BASE_PATH}/maya${MAYA_VERSION}${MAYA_INSTALL_BASE_SUFFIX})
SET(_PROJECT ${PROJECT_NAME})

INCLUDE_DIRECTORIES(${_MAYA_LOCATION}/${MAYA_INC_SUFFIX} ${OPENGL_INCLUDE_DIRS} ${GLUT_INCLUDE_DIRS})

LINK_DIRECTORIES(${_MAYA_LOCATION}/${MAYA_LIB_SUFFIX})

ADD_LIBRARY(${_PROJECT} SHARED ${SOURCE_FILES})

TARGET_LINK_LIBRARIES(${_PROJECT} ${LIBRARIES})

SET_TARGET_PROPERTIES(${_PROJECT} PROPERTIES COMPILE_DEFINITIONS "${CUSTOM_DEFINITIONS}")
SET_TARGET_PROPERTIES(${_PROJECT} PROPERTIES OUTPUT_NAME ${PROJECT_NAME})
SET_TARGET_PROPERTIES(${_PROJECT} PROPERTIES CLEAN_DIRECT_OUTPUT 1)

# Set target properties per OS
IF (WIN32)
    SET (Suffix ".mll")
    SET_TARGET_PROPERTIES(${_PROJECT} PROPERTIES SUFFIX ${Suffix} )
    SET_TARGET_PROPERTIES(${_PROJECT} PROPERTIES LINK_FLAGS "/export:initializePlugin /export:uninitializePlugin" )
ELSEIF(APPLE)
    SET (Suffix ".bundle")
    SET_TARGET_PROPERTIES(${_PROJECT} PROPERTIES PREFIX "" )
    SET_TARGET_PROPERTIES(${_PROJECT} PROPERTIES SUFFIX ${Suffix} )
ELSE(WIN32)
    SET (Suffix "")
    SET_TARGET_PROPERTIES(${_PROJECT} PROPERTIES PREFIX "" )
ENDIF(WIN32)