diff options
author | Craig Scott <craig.scott@crascit.com> | 2020-12-15 12:16:20 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2020-12-15 12:16:26 (GMT) |
commit | defd29243f442cf8ba4762844577083ac191704c (patch) | |
tree | 9be9a7572e88b7627b53eb00ab7c4f3f98df1f4f /Modules/BasicConfigVersion-SameMajorVersion.cmake.in | |
parent | 09a324fbc2794cdfd220b7a84615c535b294c41b (diff) | |
parent | 70b69b6aaf3fbc419d4ce175da1d6e13bae5f533 (diff) | |
download | CMake-defd29243f442cf8ba4762844577083ac191704c.zip CMake-defd29243f442cf8ba4762844577083ac191704c.tar.gz CMake-defd29243f442cf8ba4762844577083ac191704c.tar.bz2 |
Merge topic 'CMakePackageConfigHelpers-version-range'
70b69b6aaf Merge branch 'backport-3.19-CMakePackageConfigHelpers-version-range' into CMakePackageConfigHelpers-version-range
55c3b6a77e CMakePackageConfigHelpers: Relax restrictions on version range
7f44760991 CMakePackageConfigHelpers: Relax restrictions on version range
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5613
Diffstat (limited to 'Modules/BasicConfigVersion-SameMajorVersion.cmake.in')
-rw-r--r-- | Modules/BasicConfigVersion-SameMajorVersion.cmake.in | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/Modules/BasicConfigVersion-SameMajorVersion.cmake.in b/Modules/BasicConfigVersion-SameMajorVersion.cmake.in index 662900d..dc04e54 100644 --- a/Modules/BasicConfigVersion-SameMajorVersion.cmake.in +++ b/Modules/BasicConfigVersion-SameMajorVersion.cmake.in @@ -9,13 +9,6 @@ # The variable CVF_VERSION must be set before calling configure_file(). -if (PACKAGE_FIND_VERSION_RANGE) - message(AUTHOR_WARNING - "`find_package()` specify a version range but the version strategy " - "(SameMajorVersion) of the module `${PACKAGE_FIND_NAME}` is incompatible " - "with this request. Only the lower endpoint of the range will be used.") -endif() - set(PACKAGE_VERSION "@CVF_VERSION@") if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION) @@ -28,14 +21,30 @@ else() set(CVF_VERSION_MAJOR "@CVF_VERSION@") endif() - if(PACKAGE_FIND_VERSION_MAJOR STREQUAL CVF_VERSION_MAJOR) - set(PACKAGE_VERSION_COMPATIBLE TRUE) + if(PACKAGE_FIND_VERSION_RANGE) + # both endpoints of the range must have the expected major version + math (EXPR CVF_VERSION_MAJOR_NEXT "${CVF_VERSION_MAJOR} + 1") + if (NOT PACKAGE_FIND_VERSION_MIN_MAJOR STREQUAL CVF_VERSION_MAJOR + OR ((PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" AND NOT PACKAGE_FIND_VERSION_MAX_MAJOR STREQUAL CVF_VERSION_MAJOR) + OR (PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" AND NOT PACKAGE_FIND_VERSION_MAX VERSION_LESS_EQUAL CVF_VERSION_MAJOR_NEXT))) + set(PACKAGE_VERSION_COMPATIBLE FALSE) + elseif(PACKAGE_FIND_VERSION_MIN_MAJOR STREQUAL CVF_VERSION_MAJOR + AND ((PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_LESS_EQUAL PACKAGE_FIND_VERSION_MAX) + OR (PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" AND PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION_MAX))) + set(PACKAGE_VERSION_COMPATIBLE TRUE) + else() + set(PACKAGE_VERSION_COMPATIBLE FALSE) + endif() else() - set(PACKAGE_VERSION_COMPATIBLE FALSE) - endif() + if(PACKAGE_FIND_VERSION_MAJOR STREQUAL CVF_VERSION_MAJOR) + set(PACKAGE_VERSION_COMPATIBLE TRUE) + else() + set(PACKAGE_VERSION_COMPATIBLE FALSE) + endif() - if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION) + if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION) set(PACKAGE_VERSION_EXACT TRUE) + endif() endif() endif() |