CPackExternal.cmake 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file Copyright.txt or https://cmake.org/licensing for details.
  3. if(NOT "${CPACK_EXTERNAL_REQUESTED_VERSIONS}" STREQUAL "")
  4. unset(_found_major)
  5. foreach(_req_version IN LISTS CPACK_EXTERNAL_REQUESTED_VERSIONS)
  6. if(_req_version MATCHES "^([0-9]+)\\.([0-9]+)$")
  7. set(_req_major "${CMAKE_MATCH_1}")
  8. set(_req_minor "${CMAKE_MATCH_2}")
  9. foreach(_known_version IN LISTS CPACK_EXTERNAL_KNOWN_VERSIONS)
  10. string(REGEX MATCH
  11. "^([0-9]+)\\.([0-9]+)$"
  12. _known_version_dummy
  13. "${_known_version}"
  14. )
  15. set(_known_major "${CMAKE_MATCH_1}")
  16. set(_known_minor "${CMAKE_MATCH_2}")
  17. if(_req_major EQUAL _known_major AND NOT _known_minor LESS _req_minor)
  18. set(_found_major "${_known_major}")
  19. set(_found_minor "${_known_minor}")
  20. break()
  21. endif()
  22. endforeach()
  23. if(DEFINED _found_major)
  24. break()
  25. endif()
  26. endif()
  27. endforeach()
  28. if(DEFINED _found_major)
  29. set(CPACK_EXTERNAL_SELECTED_MAJOR "${_found_major}")
  30. set(CPACK_EXTERNAL_SELECTED_MINOR "${_found_minor}")
  31. set(CPACK_EXTERNAL_SELECTED_VERSION "${_found_major}.${_found_minor}")
  32. else()
  33. message(FATAL_ERROR
  34. "Could not find a suitable version in CPACK_EXTERNAL_REQUESTED_VERSIONS"
  35. )
  36. endif()
  37. else()
  38. list(GET CPACK_EXTERNAL_KNOWN_VERSIONS 0 CPACK_EXTERNAL_SELECTED_VERSION)
  39. string(REGEX MATCH
  40. "^([0-9]+)\\.([0-9]+)$"
  41. _dummy
  42. "${CPACK_EXTERNAL_SELECTED_VERSION}"
  43. )
  44. set(CPACK_EXTERNAL_SELECTED_MAJOR "${CMAKE_MATCH_1}")
  45. set(CPACK_EXTERNAL_SELECTED_MINOR "${CMAKE_MATCH_2}")
  46. endif()