OpenCASCADEConfigVersion.cmake 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. if (PACKAGE_FIND_VERSION_RANGE)
  11. message(AUTHOR_WARNING
  12. "`find_package()` specify a version range but the version strategy "
  13. "(ExactVersion) of the module `${PACKAGE_FIND_NAME}` is incompatible "
  14. "with this request. Only the lower endpoint of the range will be used.")
  15. endif()
  16. set(PACKAGE_VERSION "7.6.0")
  17. if("7.6.0" MATCHES "^([0-9]+)\\.([0-9]+)\\.([0-9]+)") # strip the tweak version
  18. set(CVF_VERSION_MAJOR "${CMAKE_MATCH_1}")
  19. set(CVF_VERSION_MINOR "${CMAKE_MATCH_2}")
  20. set(CVF_VERSION_PATCH "${CMAKE_MATCH_3}")
  21. if(NOT CVF_VERSION_MAJOR VERSION_EQUAL 0)
  22. string(REGEX REPLACE "^0+" "" CVF_VERSION_MAJOR "${CVF_VERSION_MAJOR}")
  23. endif()
  24. if(NOT CVF_VERSION_MINOR VERSION_EQUAL 0)
  25. string(REGEX REPLACE "^0+" "" CVF_VERSION_MINOR "${CVF_VERSION_MINOR}")
  26. endif()
  27. if(NOT CVF_VERSION_PATCH VERSION_EQUAL 0)
  28. string(REGEX REPLACE "^0+" "" CVF_VERSION_PATCH "${CVF_VERSION_PATCH}")
  29. endif()
  30. set(CVF_VERSION_NO_TWEAK "${CVF_VERSION_MAJOR}.${CVF_VERSION_MINOR}.${CVF_VERSION_PATCH}")
  31. else()
  32. set(CVF_VERSION_NO_TWEAK "7.6.0")
  33. endif()
  34. if(PACKAGE_FIND_VERSION MATCHES "^([0-9]+)\\.([0-9]+)\\.([0-9]+)") # strip the tweak version
  35. set(REQUESTED_VERSION_MAJOR "${CMAKE_MATCH_1}")
  36. set(REQUESTED_VERSION_MINOR "${CMAKE_MATCH_2}")
  37. set(REQUESTED_VERSION_PATCH "${CMAKE_MATCH_3}")
  38. if(NOT REQUESTED_VERSION_MAJOR VERSION_EQUAL 0)
  39. string(REGEX REPLACE "^0+" "" REQUESTED_VERSION_MAJOR "${REQUESTED_VERSION_MAJOR}")
  40. endif()
  41. if(NOT REQUESTED_VERSION_MINOR VERSION_EQUAL 0)
  42. string(REGEX REPLACE "^0+" "" REQUESTED_VERSION_MINOR "${REQUESTED_VERSION_MINOR}")
  43. endif()
  44. if(NOT REQUESTED_VERSION_PATCH VERSION_EQUAL 0)
  45. string(REGEX REPLACE "^0+" "" REQUESTED_VERSION_PATCH "${REQUESTED_VERSION_PATCH}")
  46. endif()
  47. set(REQUESTED_VERSION_NO_TWEAK
  48. "${REQUESTED_VERSION_MAJOR}.${REQUESTED_VERSION_MINOR}.${REQUESTED_VERSION_PATCH}")
  49. else()
  50. set(REQUESTED_VERSION_NO_TWEAK "${PACKAGE_FIND_VERSION}")
  51. endif()
  52. if(REQUESTED_VERSION_NO_TWEAK STREQUAL CVF_VERSION_NO_TWEAK)
  53. set(PACKAGE_VERSION_COMPATIBLE TRUE)
  54. else()
  55. set(PACKAGE_VERSION_COMPATIBLE FALSE)
  56. endif()
  57. if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
  58. set(PACKAGE_VERSION_EXACT TRUE)
  59. endif()
  60. # if the installed project requested no architecture check, don't perform the check
  61. if("FALSE")
  62. return()
  63. endif()
  64. # if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it:
  65. if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "8" STREQUAL "")
  66. return()
  67. endif()
  68. # check that the installed version has the same 32/64bit-ness as the one which is currently searching:
  69. if(NOT CMAKE_SIZEOF_VOID_P STREQUAL "8")
  70. math(EXPR installedBits "8 * 8")
  71. set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)")
  72. set(PACKAGE_VERSION_UNSUITABLE TRUE)
  73. endif()