BasicConfigVersion-ExactVersion.cmake.in 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # This is a basic version file for the Config-mode of find_package().
  2. # It is used by write_basic_package_version_file() as input file for configure_file()
  3. # to create a version-file which can be installed along a config.cmake file.
  4. #
  5. # The created file sets PACKAGE_VERSION_EXACT if the current version string and
  6. # the requested version string are exactly the same and it sets
  7. # PACKAGE_VERSION_COMPATIBLE if the current version is equal to the requested version.
  8. # The tweak version component is ignored.
  9. # The variable CVF_VERSION must be set before calling configure_file().
  10. set(PACKAGE_VERSION "@CVF_VERSION@")
  11. if("@CVF_VERSION@" MATCHES "^([0-9]+\\.[0-9]+\\.[0-9]+)\\.") # strip the tweak version
  12. set(CVF_VERSION_NO_TWEAK "${CMAKE_MATCH_1}")
  13. else()
  14. set(CVF_VERSION_NO_TWEAK "@CVF_VERSION@")
  15. endif()
  16. if(PACKAGE_FIND_VERSION MATCHES "^([0-9]+\\.[0-9]+\\.[0-9]+)\\.") # strip the tweak version
  17. set(REQUESTED_VERSION_NO_TWEAK "${CMAKE_MATCH_1}")
  18. else()
  19. set(REQUESTED_VERSION_NO_TWEAK "${PACKAGE_FIND_VERSION}")
  20. endif()
  21. if(REQUESTED_VERSION_NO_TWEAK STREQUAL CVF_VERSION_NO_TWEAK)
  22. set(PACKAGE_VERSION_COMPATIBLE TRUE)
  23. else()
  24. set(PACKAGE_VERSION_COMPATIBLE FALSE)
  25. endif()
  26. if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
  27. set(PACKAGE_VERSION_EXACT TRUE)
  28. endif()
  29. # if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it:
  30. if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "@CMAKE_SIZEOF_VOID_P@" STREQUAL "")
  31. return()
  32. endif()
  33. # check that the installed version has the same 32/64bit-ness as the one which is currently searching:
  34. if(NOT CMAKE_SIZEOF_VOID_P STREQUAL "@CMAKE_SIZEOF_VOID_P@")
  35. math(EXPR installedBits "@CMAKE_SIZEOF_VOID_P@ * 8")
  36. set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)")
  37. set(PACKAGE_VERSION_UNSUITABLE TRUE)
  38. endif()