Fix FindMaya.cmake

- switch PATHS to HINTS to make sure that we pick up the correct location for various files & libs
- fix the list append to dereference variables properly
- minor code style cleanup

fixes #266
This commit is contained in:
manuelk 2014-02-26 17:20:01 -08:00
parent 37f25250f1
commit 6d367f7f13

View File

@ -51,54 +51,60 @@
# License text for the above reference.) # License text for the above reference.)
if(APPLE) if(APPLE)
find_path(MAYA_BASE_DIR ../../devkit/include/maya/MFn.h PATH find_path(MAYA_BASE_DIR
${MAYA_LOCATION} ../../devkit/include/maya/MFn.h
$ENV{MAYA_LOCATION} HINTS
"/Applications/Autodesk/maya2014/Maya.app/Contents" ${MAYA_LOCATION}
"/Applications/Autodesk/maya2013.5/Maya.app/Contents" $ENV{MAYA_LOCATION}
"/Applications/Autodesk/maya2013/Maya.app/Contents" "/Applications/Autodesk/maya2014/Maya.app/Contents"
"/Applications/Autodesk/maya2012.17/Maya.app/Contents" "/Applications/Autodesk/maya2013.5/Maya.app/Contents"
"/Applications/Autodesk/maya2012/Maya.app/Contents" "/Applications/Autodesk/maya2013/Maya.app/Contents"
"/Applications/Autodesk/maya2011/Maya.app/Contents" "/Applications/Autodesk/maya2012.17/Maya.app/Contents"
"/Applications/Autodesk/maya2010/Maya.app/Contents" "/Applications/Autodesk/maya2012/Maya.app/Contents"
"/Applications/Autodesk/maya2011/Maya.app/Contents"
"/Applications/Autodesk/maya2010/Maya.app/Contents"
) )
find_path(MAYA_LIBRARY_DIR libOpenMaya.dylib find_path(MAYA_LIBRARY_DIR libOpenMaya.dylib
PATHS HINTS
${MAYA_LOCATION} ${MAYA_LOCATION}
$ENV{MAYA_LOCATION} $ENV{MAYA_LOCATION}
${MAYA_BASE_DIR} ${MAYA_BASE_DIR}
PATH_SUFFIXES PATH_SUFFIXES
Maya.app/contents/MacOS/ Maya.app/contents/MacOS/
DOC DOC
"Maya's libraries path" "Maya's libraries path"
) )
endif(APPLE) endif(APPLE)
if(UNIX) if(UNIX)
find_path(MAYA_BASE_DIR include/maya/MFn.h PATH find_path(MAYA_BASE_DIR
${MAYA_LOCATION} include/maya/MFn.h
$ENV{MAYA_LOCATION} HINTS
"/usr/autodesk/maya2013-x64" ${MAYA_LOCATION}
"/usr/autodesk/maya2012.17-x64" $ENV{MAYA_LOCATION}
"/usr/autodesk/maya2012-x64" "/usr/autodesk/maya2013-x64"
"/usr/autodesk/maya2011-x64" "/usr/autodesk/maya2012.17-x64"
"/usr/autodesk/maya2010-x64" "/usr/autodesk/maya2012-x64"
"/usr/autodesk/maya2011-x64"
"/usr/autodesk/maya2010-x64"
) )
find_path(MAYA_LIBRARY_DIR libOpenMaya.so find_path(MAYA_LIBRARY_DIR
PATHS libOpenMaya.so
HINTS
${MAYA_LOCATION} ${MAYA_LOCATION}
$ENV{MAYA_LOCATION} $ENV{MAYA_LOCATION}
${MAYA_BASE_DIR} ${MAYA_BASE_DIR}
PATH_SUFFIXES PATH_SUFFIXES
lib/ lib/
DOC DOC
"Maya's libraries path" "Maya's libraries path"
) )
endif(UNIX) endif(UNIX)
if(WIN32) if(WIN32)
find_path(MAYA_BASE_DIR include/maya/MFn.h find_path(MAYA_BASE_DIR
PATH include/maya/MFn.h
HINTS
${MAYA_LOCATION} ${MAYA_LOCATION}
$ENV{MAYA_LOCATION} $ENV{MAYA_LOCATION}
"C:/Program Files/Autodesk/Maya2013.5-x64" "C:/Program Files/Autodesk/Maya2013.5-x64"
@ -122,46 +128,50 @@ if(WIN32)
"C:/Program Files (x86)/Autodesk/Maya2010" "C:/Program Files (x86)/Autodesk/Maya2010"
"C:/Autodesk/maya-2010x64" "C:/Autodesk/maya-2010x64"
) )
find_path(MAYA_LIBRARY_DIR OpenMaya.lib find_path(MAYA_LIBRARY_DIR
PATHS OpenMaya.lib
HINTS
${MAYA_LOCATION} ${MAYA_LOCATION}
$ENV{MAYA_LOCATION} $ENV{MAYA_LOCATION}
${MAYA_BASE_DIR} ${MAYA_BASE_DIR}
PATH_SUFFIXES PATH_SUFFIXES
lib/ lib/
DOC DOC
"Maya's libraries path" "Maya's libraries path"
) )
endif(WIN32) endif(WIN32)
find_path(MAYA_INCLUDE_DIR maya/MFn.h find_path(MAYA_INCLUDE_DIR
PATHS maya/MFn.h
HINTS
${MAYA_LOCATION} ${MAYA_LOCATION}
$ENV{MAYA_LOCATION} $ENV{MAYA_LOCATION}
${MAYA_BASE_DIR} ${MAYA_BASE_DIR}
PATH_SUFFIXES PATH_SUFFIXES
../../devkit/include/ ../../devkit/include/
include/ include/
DOC DOC
"Maya's devkit headers path" "Maya's devkit headers path"
) )
find_path(MAYA_LIBRARY_DIR OpenMaya find_path(MAYA_LIBRARY_DIR
PATHS OpenMaya
HINTS
${MAYA_LOCATION} ${MAYA_LOCATION}
$ENV{MAYA_LOCATION} $ENV{MAYA_LOCATION}
${MAYA_BASE_DIR} ${MAYA_BASE_DIR}
PATH_SUFFIXES PATH_SUFFIXES
../../devkit/include/ ../../devkit/include/
include/ include/
DOC DOC
"Maya's devkit headers path" "Maya's devkit headers path"
) )
list(APPEND MAYA_INCLUDE_DIRS ${MAYA_INCLUDE_DIR}) list(APPEND MAYA_INCLUDE_DIRS ${MAYA_INCLUDE_DIR})
find_path(MAYA_DEVKIT_INC_DIR GL/glext.h find_path(MAYA_DEVKIT_INC_DIR
PATHS GL/glext.h
HINTS
${MAYA_LOCATION} ${MAYA_LOCATION}
$ENV{MAYA_LOCATION} $ENV{MAYA_LOCATION}
${MAYA_BASE_DIR} ${MAYA_BASE_DIR}
@ -186,25 +196,28 @@ foreach(MAYA_LIB
cg cg
cgGL) cgGL)
find_library(MAYA_${MAYA_LIB}_LIBRARY ${MAYA_LIB} find_library(MAYA_${MAYA_LIB}_LIBRARY
PATHS ${MAYA_LIB}
HINTS
${MAYA_LOCATION} ${MAYA_LOCATION}
$ENV{MAYA_LOCATION} $ENV{MAYA_LOCATION}
${MAYA_BASE_DIR} ${MAYA_BASE_DIR}
PATH_SUFFIXES PATH_SUFFIXES
MacOS/ MacOS/
lib/ lib/
DOC DOC
"Maya's ${MAYA_LIB} library path" "Maya's ${MAYA_LIB} library path"
) )
if (MAYA_${MAYA_LIB}_LIBRARY) if (MAYA_${MAYA_LIB}_LIBRARY)
list(APPEND ${MAYA_LIBRARIES} MAYA_${MAYA_LIB}_LIBRARY) list(APPEND MAYA_LIBRARIES ${MAYA_${MAYA_LIB}_LIBRARY})
endif() endif()
endforeach(MAYA_LIB) endforeach(MAYA_LIB)
find_program(MAYA_EXECUTABLE maya find_program(MAYA_EXECUTABLE
PATHS maya
HINTS
${MAYA_LOCATION} ${MAYA_LOCATION}
$ENV{MAYA_LOCATION} $ENV{MAYA_LOCATION}
${MAYA_BASE_DIR} ${MAYA_BASE_DIR}
@ -226,11 +239,11 @@ endif()
# all listed variables are TRUE # all listed variables are TRUE
include(FindPackageHandleStandardArgs) include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Maya find_package_handle_standard_args(Maya
REQUIRED_VARS REQUIRED_VARS
${MAYA_LIBRARIES} MAYA_EXECUTABLE
MAYA_EXECUTABLE
MAYA_INCLUDE_DIRS MAYA_INCLUDE_DIRS
MAYA_LIBRARIES
VERSION_VAR VERSION_VAR
MAYA_API_VERSION MAYA_API_VERSION
) )