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

StackOverflow https://stackoverflow.com/questions/4851825

  •  27-10-2019
  •  | 
  •  

سؤال

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?

هل كانت مفيدة؟

المحلول

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

نصائح أخرى

You can find the Qt4 find script in your CMake install folder under share\cmake-2.8\Modules.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top