Skip to content

Commit

Permalink
Set up the simplified cmake build
Browse files Browse the repository at this point in the history
  • Loading branch information
tbttfox committed Dec 18, 2021
1 parent 680005c commit ae6ac83
Show file tree
Hide file tree
Showing 4 changed files with 160 additions and 65 deletions.
79 changes: 14 additions & 65 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,74 +1,23 @@
cmake_minimum_required(VERSION 2.6)
project(harbieLocator)

SET(MAYA_VERSION 2019 CACHE STRING "Maya version number")
SET(SOURCE_FILES
"harbieCurve.h"
"harbieLocator.h"
"shapesDefinition.h"
"shapesDefinitionCurve.h"
"harbieCurve.cpp"
"harbieLocator.cpp"
"PluginMain.cpp"
)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
SET(MAYA_VERSION 2020 CACHE STRING "Maya version number")

FIND_PACKAGE(OpenGL REQUIRED)

# 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 "-x32")
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" "clew" ${OPENGL_LIBRARIES})

SET(_MAYA_LOCATION ${MAYA_INSTALL_BASE_PATH}/maya${MAYA_VERSION}${MAYA_INSTALL_BASE_SUFFIX})
SET(_PROJECT ${PROJECT_NAME})
file(GLOB SOURCE_FILES "src/*.*")

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)

IF (WIN32)
SET_TARGET_PROPERTIES(${_PROJECT} PROPERTIES SUFFIX ".mll" )
SET_TARGET_PROPERTIES(${_PROJECT} PROPERTIES LINK_FLAGS "/export:initializePlugin /export:uninitializePlugin" )
ELSEIF(APPLE)
SET_TARGET_PROPERTIES(${_PROJECT} PROPERTIES PREFIX "" )
SET_TARGET_PROPERTIES(${_PROJECT} PROPERTIES SUFFIX ".bundle" )
ELSE(WIN32)
SET_TARGET_PROPERTIES(${_PROJECT} PROPERTIES PREFIX "" )
ENDIF(WIN32)
FIND_PACKAGE(OpenGL REQUIRED)
FIND_PACKAGE(Maya REQUIRED)

set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/../output)
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT ${PROJECT_NAME})

set(USERBINPATH $"C:/Users/guillaume/Documents/maya/2016.5/plug-ins")
include_directories(${MAYA_INCLUDE_DIR} maya lib ${OPENGL_INCLUDE_DIRS} ${GLUT_INCLUDE_DIRS})
link_directories(${MAYA_LIBRARY_DIR})
add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES})
target_link_libraries(${PROJECT_NAME} ${MAYA_LIBRARIES} ${OPENGL_LIBRARIES})

add_custom_command(TARGET ${PROJECT_NAME}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy "$(ProjectDir)/$<CONFIGURATION>/${PROJECT_NAME}.mll" "$USERBINPATH"
)
MAYA_PLUGIN(${PROJECT_NAME})

install(TARGETS ${PROJECT_NAME} ${MAYA_TARGET_TYPE} DESTINATION plug-ins/win64/${MAYA_VERSION})
#install(CODE "execute_process(COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/scripts/buildModFile.py)")
127 changes: 127 additions & 0 deletions cmake/FindMaya.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# The MIT License (MIT)
#
# Copyright (c) 2015 Chad Vernon
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

# - Maya finder module
#
# Variables that will be defined:
# MAYA_FOUND Defined if a Maya installation has been detected
# MAYA_EXECUTABLE Path to Maya's executable
# MAYA_<lib>_FOUND Defined if <lib> has been found
# MAYA_<lib>_LIBRARY Path to <lib> library
# MAYA_INCLUDE_DIR Path to the devkit's include directories
# MAYA_LIBRARIES All the Maya libraries
#

# Set a default Maya version if not specified
if(NOT DEFINED MAYA_VERSION)
set(MAYA_VERSION 2016 CACHE STRING "Maya version")
endif()

# OS Specific environment setup
set(MAYA_COMPILE_DEFINITIONS "REQUIRE_IOSTREAM;_BOOL")
set(MAYA_INSTALL_BASE_SUFFIX "")
set(MAYA_INC_SUFFIX "include")
set(MAYA_LIB_SUFFIX "lib")
set(MAYA_BIN_SUFFIX "bin")
set(MAYA_TARGET_TYPE LIBRARY)
if(WIN32)
# Windows
set(MAYA_INSTALL_BASE_DEFAULT "C:/Program Files/Autodesk")
set(MAYA_COMPILE_DEFINITIONS "${MAYA_COMPILE_DEFINITIONS};NT_PLUGIN")
set(OPENMAYA OpenMaya.lib)
set(MAYA_PLUGIN_EXTENSION ".mll")
set(MAYA_TARGET_TYPE RUNTIME)
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(MAYA_BIN_SUFFIX "Maya.app/Contents/bin/")
set(MAYA_COMPILE_DEFINITIONS "${MAYA_COMPILE_DEFINITIONS};OSMac_")
set(OPENMAYA libOpenMaya.dylib)
set(MAYA_PLUGIN_EXTENSION ".bundle")
else()
# Linux
set(MAYA_COMPILE_DEFINITIONS "${MAYA_COMPILE_DEFINITIONS};LINUX")
set(MAYA_INSTALL_BASE_DEFAULT /usr/autodesk)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
if(MAYA_VERSION LESS 2016)
SET(MAYA_INSTALL_BASE_SUFFIX -x64)
endif()
set(OPENMAYA libOpenMaya.so)
set(MAYA_PLUGIN_EXTENSION ".so")
endif()

set(MAYA_INSTALL_BASE_PATH ${MAYA_INSTALL_BASE_DEFAULT} CACHE STRING
"Root path containing your maya installations, e.g. /usr/autodesk or /Applications/Autodesk/")

set(MAYA_LOCATION ${MAYA_INSTALL_BASE_PATH}/Maya${MAYA_VERSION}${MAYA_INSTALL_BASE_SUFFIX})

# Maya library directory
find_path(MAYA_LIBRARY_DIR ${OPENMAYA}
PATHS
${MAYA_LOCATION}
$ENV{MAYA_LOCATION}
PATH_SUFFIXES
"${MAYA_LIB_SUFFIX}/"
DOC "Maya library path"
)

# Maya include directory
find_path(MAYA_INCLUDE_DIR maya/MFn.h
PATHS
${MAYA_LOCATION}
$ENV{MAYA_LOCATION}
PATH_SUFFIXES
"${MAYA_INC_SUFFIX}/"
DOC "Maya include path"
)

# Maya libraries
set(_MAYA_LIBRARIES OpenMaya OpenMayaAnim OpenMayaFX OpenMayaRender OpenMayaUI Foundation clew)
foreach(MAYA_LIB ${_MAYA_LIBRARIES})
find_library(MAYA_${MAYA_LIB}_LIBRARY NAMES ${MAYA_LIB} PATHS ${MAYA_LIBRARY_DIR}
NO_DEFAULT_PATH)
if (MAYA_${MAYA_LIB}_LIBRARY)
set(MAYA_LIBRARIES ${MAYA_LIBRARIES} ${MAYA_${MAYA_LIB}_LIBRARY})
endif()
endforeach()

if (APPLE AND ${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
# Clang and Maya needs to use libstdc++
set(MAYA_CXX_FLAGS "-std=c++0x -stdlib=libstdc++")
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Maya DEFAULT_MSG MAYA_INCLUDE_DIR MAYA_LIBRARIES)

function(MAYA_PLUGIN _target)
if (WIN32)
set_target_properties(${_target} PROPERTIES
LINK_FLAGS "/export:initializePlugin /export:uninitializePlugin"
)
endif()
set_target_properties(${_target} PROPERTIES
COMPILE_DEFINITIONS "${MAYA_COMPILE_DEFINITIONS}"
PREFIX ""
SUFFIX ${MAYA_PLUGIN_EXTENSION})
endfunction()
19 changes: 19 additions & 0 deletions mayaConfigure.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
setlocal

SET MAYA_VERSION=2022
SET BUILD=mayabuild_%MAYA_VERSION%
SET COMPILER=Visual Studio 15 2017 Win64

SET PFX=%~dp0
cd %PFX%
rmdir %BUILD% /s /q
mkdir %BUILD%
cd %BUILD%

cmake ^
-DMAYA_VERSION=%MAYA_VERSION% ^
-G "%COMPILER%" ..\

cmake --build . --config Release --target Install

pause
File renamed without changes.

0 comments on commit ae6ac83

Please sign in to comment.