summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'Modules')
-rw-r--r--Modules/BasicConfigVersion-AnyNewerVersion.cmake.in21
-rw-r--r--Modules/BasicConfigVersion-ExactVersion.cmake.in7
-rw-r--r--Modules/BasicConfigVersion-SameMajorVersion.cmake.in7
-rw-r--r--Modules/BasicConfigVersion-SameMinorVersion.cmake.in7
-rw-r--r--Modules/CMakePackageConfigHelpers.cmake5
5 files changed, 42 insertions, 5 deletions
diff --git a/Modules/BasicConfigVersion-AnyNewerVersion.cmake.in b/Modules/BasicConfigVersion-AnyNewerVersion.cmake.in
index a6e5fda..46b8b2a 100644
--- a/Modules/BasicConfigVersion-AnyNewerVersion.cmake.in
+++ b/Modules/BasicConfigVersion-AnyNewerVersion.cmake.in
@@ -9,12 +9,23 @@
set(PACKAGE_VERSION "@CVF_VERSION@")
-if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
- set(PACKAGE_VERSION_COMPATIBLE FALSE)
+if (PACKAGE_FIND_VERSION_RANGE)
+ # Package version must be in the requested version range
+ if ((PACKAGE_FIND_VERSION_RANGE_MIN STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION_MIN)
+ OR ((PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_GREATER PACKAGE_FIND_VERSION_MAX)
+ OR (PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" AND PACKAGE_VERSION VERSION_GREATER_EQUAL PACKAGE_FIND_VERSION_MAX)))
+ set(PACKAGE_VERSION_COMPATIBLE FALSE)
+ else()
+ set(PACKAGE_VERSION_COMPATIBLE TRUE)
+ endif()
else()
- set(PACKAGE_VERSION_COMPATIBLE TRUE)
- if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
- set(PACKAGE_VERSION_EXACT TRUE)
+ if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
+ set(PACKAGE_VERSION_COMPATIBLE FALSE)
+ else()
+ set(PACKAGE_VERSION_COMPATIBLE TRUE)
+ if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
+ set(PACKAGE_VERSION_EXACT TRUE)
+ endif()
endif()
endif()
diff --git a/Modules/BasicConfigVersion-ExactVersion.cmake.in b/Modules/BasicConfigVersion-ExactVersion.cmake.in
index 43fc4d0..3507a22 100644
--- a/Modules/BasicConfigVersion-ExactVersion.cmake.in
+++ b/Modules/BasicConfigVersion-ExactVersion.cmake.in
@@ -9,6 +9,13 @@
# 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 "
+ "(ExactVersion) 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("@CVF_VERSION@" MATCHES "^([0-9]+\\.[0-9]+\\.[0-9]+)\\.") # strip the tweak version
diff --git a/Modules/BasicConfigVersion-SameMajorVersion.cmake.in b/Modules/BasicConfigVersion-SameMajorVersion.cmake.in
index 8c3b6a2..662900d 100644
--- a/Modules/BasicConfigVersion-SameMajorVersion.cmake.in
+++ b/Modules/BasicConfigVersion-SameMajorVersion.cmake.in
@@ -9,6 +9,13 @@
# 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)
diff --git a/Modules/BasicConfigVersion-SameMinorVersion.cmake.in b/Modules/BasicConfigVersion-SameMinorVersion.cmake.in
index e2030d2..bddf4ce 100644
--- a/Modules/BasicConfigVersion-SameMinorVersion.cmake.in
+++ b/Modules/BasicConfigVersion-SameMinorVersion.cmake.in
@@ -10,6 +10,13 @@
# 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 "
+ "(SameMinorVersion) 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)
diff --git a/Modules/CMakePackageConfigHelpers.cmake b/Modules/CMakePackageConfigHelpers.cmake
index 22fc953..50d7605 100644
--- a/Modules/CMakePackageConfigHelpers.cmake
+++ b/Modules/CMakePackageConfigHelpers.cmake
@@ -159,6 +159,11 @@ If your project has more elaborated version matching rules, you will need to
write your own custom ``ConfigVersion.cmake`` file instead of using this
macro.
+.. note:: ``COMPATIBILITY_MODE`` ``AnyNewerVersion`` handles the version range
+ if any is specified (see :command:`find_package` command for the details).
+ All other modes are incompatible with version range and will display an
+ author warning if a one is specified.
+
If ``ARCH_INDEPENDENT`` is given, the installed package version will be
considered compatible even if it was built for a different architecture than
the requested architecture. Otherwise, an architecture check will be performed,