Search code examples
cmakemaya

How to design a custom cmake FindOOXX module with versioning like FindQt4?


I would like to design a cmake FindOOXX module for Autodesk Maya with support of versioning, just like what FindQt4.cmake provides. ex,

find_package(Qt4 4.4.3)
include(${QT_USE_FILE})
add_executable(myexe main.cpp)
target_link_libraries(myexe ${QT_LIBRARIES})

Does anyone has a simple but complete cmake module sample like this?


Solution

  • In the CMake modules directory there is a file readme.txt which contains useful information for CMake module writers. This is the relevant section from that file on how version numbers are passed to the module:

    If any version numbers are given to the command it will set the
    following variables before loading the module:
    
      XXX_FIND_VERSION       = full requested version string
      XXX_FIND_VERSION_MAJOR = major version if requested, else 0
      XXX_FIND_VERSION_MINOR = minor version if requested, else 0
      XXX_FIND_VERSION_PATCH = patch version if requested, else 0
      XXX_FIND_VERSION_TWEAK = tweak version if requested, else 0
      XXX_FIND_VERSION_COUNT = number of version components, 0 to 4
      XXX_FIND_VERSION_EXACT = true if EXACT option was given