summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorCraig Scott <craig.scott@crascit.com>2017-11-22 12:29:09 (GMT)
committerKitware Robot <kwrobot@kitware.com>2017-11-22 12:29:33 (GMT)
commit51ccfaacb88303bb2774cead91069e1c25888137 (patch)
tree54b172cc093017f9c4a049917f8f7deff3871745 /Modules
parent7dbeb3ac5c7e0985063a5473c98fdbee102f2a4d (diff)
parentd18ff3a5c662a9f5d3b44236ea0084b154f32a9b (diff)
downloadCMake-51ccfaacb88303bb2774cead91069e1c25888137.zip
CMake-51ccfaacb88303bb2774cead91069e1c25888137.tar.gz
CMake-51ccfaacb88303bb2774cead91069e1c25888137.tar.bz2
Merge topic 'WriteBasicConfigVersionFile_SameMinorVersion'
d18ff3a5 WriteBasicConfigVersionFile: Fix messages in ExactVersion tests 16a93de0 WriteBasicConfigVersionFile: Add SameMinorVersion COMPATIBILITY option Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: Claudio <claudio.fantacci@gmail.com> Merge-request: !1507
Diffstat (limited to 'Modules')
-rw-r--r--Modules/BasicConfigVersion-SameMinorVersion.cmake.in50
-rw-r--r--Modules/CMakePackageConfigHelpers.cmake12
-rw-r--r--Modules/WriteBasicConfigVersionFile.cmake2
3 files changed, 58 insertions, 6 deletions
diff --git a/Modules/BasicConfigVersion-SameMinorVersion.cmake.in b/Modules/BasicConfigVersion-SameMinorVersion.cmake.in
new file mode 100644
index 0000000..59ca253
--- /dev/null
+++ b/Modules/BasicConfigVersion-SameMinorVersion.cmake.in
@@ -0,0 +1,50 @@
+# This is a basic version file for the Config-mode of find_package().
+# It is used by write_basic_package_version_file() as input file for configure_file()
+# to create a version-file which can be installed along a config.cmake file.
+#
+# The created file sets PACKAGE_VERSION_EXACT if the current version string and
+# the requested version string are exactly the same and it sets
+# PACKAGE_VERSION_COMPATIBLE if the current version is >= requested version,
+# but only if the requested major and minor versions are the same as the current
+# one.
+# The variable CVF_VERSION must be set before calling configure_file().
+
+
+set(PACKAGE_VERSION "@CVF_VERSION@")
+
+if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
+ set(PACKAGE_VERSION_COMPATIBLE FALSE)
+else()
+
+ if("@CVF_VERSION@" MATCHES "^([0-9]+)\\.([0-9]+)")
+ set(CVF_VERSION_MAJOR "${CMAKE_MATCH_1}")
+ set(CVF_VERSION_MINOR "${CMAKE_MATCH_2}")
+ else()
+ set(CVF_VERSION_MAJOR "@CVF_VERSION@")
+ set(CVF_VERSION_MINOR "")
+ endif()
+
+ if((PACKAGE_FIND_VERSION_MAJOR STREQUAL CVF_VERSION_MAJOR) AND
+ (PACKAGE_FIND_VERSION_MINOR STREQUAL CVF_VERSION_MINOR))
+ set(PACKAGE_VERSION_COMPATIBLE TRUE)
+ else()
+ set(PACKAGE_VERSION_COMPATIBLE FALSE)
+ endif()
+
+ if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
+ set(PACKAGE_VERSION_EXACT TRUE)
+ endif()
+endif()
+
+
+# if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it:
+if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "@CMAKE_SIZEOF_VOID_P@" STREQUAL "")
+ return()
+endif()
+
+# check that the installed version has the same 32/64bit-ness as the one which is currently searching:
+if(NOT CMAKE_SIZEOF_VOID_P STREQUAL "@CMAKE_SIZEOF_VOID_P@")
+ math(EXPR installedBits "@CMAKE_SIZEOF_VOID_P@ * 8")
+ set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)")
+ set(PACKAGE_VERSION_UNSUITABLE TRUE)
+endif()
diff --git a/Modules/CMakePackageConfigHelpers.cmake b/Modules/CMakePackageConfigHelpers.cmake
index f5a8e59..e37f34f 100644
--- a/Modules/CMakePackageConfigHelpers.cmake
+++ b/Modules/CMakePackageConfigHelpers.cmake
@@ -122,7 +122,7 @@
#
# write_basic_package_version_file(<filename>
# [VERSION <major.minor.patch>]
-# COMPATIBILITY <AnyNewerVersion|SameMajorVersion|ExactVersion> )
+# COMPATIBILITY <AnyNewerVersion|SameMajorVersion|SameMinorVersion|ExactVersion> )
#
#
# Writes a file for use as ``<package>ConfigVersion.cmake`` file to
@@ -144,6 +144,9 @@
# requested, e.g. version 2.0 will not be considered compatible if 1.0 is
# requested. This mode should be used for packages which guarantee backward
# compatibility within the same major version.
+# If ``SameMinorVersion`` is used, the behaviour is the same as
+# ``SameMajorVersion``, but both major and minor version must be the same as
+# requested, e.g version 0.2 will not be compatible if 0.1 is requested.
# If ``ExactVersion`` is used, then the package is only considered compatible if
# the requested version matches exactly its own version number (not considering
# the tweak version). For example, version 1.2.3 of a package is only
@@ -154,10 +157,9 @@
# macro.
#
# Internally, this macro executes :command:`configure_file()` to create the
-# resulting version file. Depending on the ``COMPATIBILITY``, either the file
-# ``BasicConfigVersion-SameMajorVersion.cmake.in`` or
-# ``BasicConfigVersion-AnyNewerVersion.cmake.in`` is used. Please note that
-# these two files are internal to CMake and you should not call
+# resulting version file. Depending on the ``COMPATIBILITY``, the corresponding
+# ``BasicConfigVersion-<COMPATIBILITY>.cmake.in`` file is used.
+# Please note that these files are internal to CMake and you should not call
# :command:`configure_file()` on them yourself, but they can be used as starting
# point to create more sophisticted custom ``ConfigVersion.cmake`` files.
#
diff --git a/Modules/WriteBasicConfigVersionFile.cmake b/Modules/WriteBasicConfigVersionFile.cmake
index 7c9467a..2f7c80a 100644
--- a/Modules/WriteBasicConfigVersionFile.cmake
+++ b/Modules/WriteBasicConfigVersionFile.cmake
@@ -11,7 +11,7 @@
#
# WRITE_BASIC_CONFIG_VERSION_FILE( filename
# [VERSION major.minor.patch]
-# COMPATIBILITY (AnyNewerVersion|SameMajorVersion)
+# COMPATIBILITY (AnyNewerVersion|SameMajorVersion|SameMinorVersion|ExactVersion)
# )
#
#