# FindMaya.cmake # CMake module to find Maya installation # # This module defines: # MAYA_FOUND - True if Maya was found # MAYA_VERSION - Maya version (e.g., Maya2023) # MAYA_LOCATION - Maya installation directory # MAYA_INCLUDE_DIR - Maya include directory # MAYA_LIBRARY - Maya library directory # MAYA_LIBRARIES - List of Maya libraries to link # Use environment variable if set if(NOT DEFINED MAYA_LOCATION) if(DEFINED ENV{MAYA_LOCATION}) set(MAYA_LOCATION $ENV{MAYA_LOCATION}) endif() endif() # Default Maya version set(MAYA_VERSION "Maya2023") if(MAYA_LOCATION) # Extract Maya version from path string(REGEX MATCH "Maya[0-9]{4}" MAYA_VERSION_FOUND "${MAYA_LOCATION}") if(MAYA_VERSION_FOUND) set(MAYA_VERSION "${MAYA_VERSION_FOUND}") endif() else() # Try to find Maya in common locations find_path(MAYA_INCLUDE_DIR NAMES maya/MApiVersion.h PATHS "C:/Program Files/Autodesk/Maya2023/include" "C:/Program Files/Autodesk/Maya2024/include" "C:/Program Files/Autodesk/Maya2025/include" "C:/Program Files/Autodesk/Maya2026/include" "C:/Program Files/Autodesk/Maya2022/include" DOC "Maya include directory" ) # If found, extract version from path if(MAYA_INCLUDE_DIR) string(REGEX MATCH "Maya[0-9]{4}" MAYA_VERSION_FOUND "${MAYA_INCLUDE_DIR}") if(MAYA_VERSION_FOUND) set(MAYA_VERSION "${MAYA_VERSION_FOUND}") string(REPLACE "/include" "" MAYA_LOCATION "${MAYA_INCLUDE_DIR}") string(REPLACE "/include" "" MAYA_LOCATION "${MAYA_LOCATION}") endif() endif() endif() # Find Maya libraries if location is known if(MAYA_LOCATION) # Construct library paths set(MAYA_LIB_DIR "${MAYA_LOCATION}/lib") # Find Foundation library find_library(FOUNDATION_LIBRARY NAMES Foundation PATHS "${MAYA_LIB_DIR}" DOC "Maya Foundation library" ) # Find OpenMaya library find_library(OPENMAYA_LIBRARY NAMES OpenMaya PATHS "${MAYA_LIB_DIR}" DOC "Maya OpenMaya library" ) # Find OpenMayaUI library find_library(OPENMAYAUI_LIBRARY NAMES OpenMayaUI PATHS "${MAYA_LIB_DIR}" DOC "Maya OpenMayaUI library" ) # Find OpenMayaAnim library find_library(OPENMAYAANIM_LIBRARY NAMES OpenMayaAnim PATHS "${MAYA_LIB_DIR}" DOC "Maya OpenMayaAnim library" ) # Find OpenMayaRender library find_library(OPENMAYARENDER_LIBRARY NAMES OpenMayaRender PATHS "${MAYA_LIB_DIR}" DOC "Maya OpenMayaRender library" ) # Collect libraries set(MAYA_LIBRARIES) if(FOUNDATION_LIBRARY) list(APPEND MAYA_LIBRARIES "${FOUNDATION_LIBRARY}") endif() if(OPENMAYA_LIBRARY) list(APPEND MAYA_LIBRARIES "${OPENMAYA_LIBRARY}") endif() if(OPENMAYAUI_LIBRARY) list(APPEND MAYA_LIBRARIES "${OPENMAYAUI_LIBRARY}") endif() if(OPENMAYAANIM_LIBRARY) list(APPEND MAYA_LIBRARIES "${OPENMAYAANIM_LIBRARY}") endif() if(OPENMAYARENDER_LIBRARY) list(APPEND MAYA_LIBRARIES "${OPENMAYARENDER_LIBRARY}") endif() # Set include directory set(MAYA_INCLUDE_DIR "${MAYA_LOCATION}/include" CACHE PATH "Maya include directory") endif() # Handle QUIET and REQUIRED arguments include(FindPackageHandleStandardArgs) find_package_handle_standard_args(Maya REQUIRED_VARS MAYA_LOCATION MAYA_INCLUDE_DIR MAYA_LIBRARIES VERSION_VAR MAYA_VERSION ) # Mark as advanced mark_as_advanced(MAYA_INCLUDE_DIR MAYA_LIBRARY MAYA_LOCATION) # Print status message if(NOT Maya_FIND_QUIETLY) if(MAYA_FOUND) message(STATUS "Found Maya ${MAYA_VERSION}: ${MAYA_LOCATION}") else() message(STATUS "Maya not found. Set MAYA_LOCATION environment variable.") endif() endif()