mirror of
https://github.com/reactos/CMake.git
synced 2025-02-01 09:35:03 +00:00
WriteBasicConfigVersionFile: Add SameMinorVersion COMPATIBILITY option
This commit is contained in:
parent
566f77b7f9
commit
16a93de0a8
@ -0,0 +1,5 @@
|
||||
WriteBasicConfigFile_SameMinorVersion
|
||||
-------------------------------------
|
||||
|
||||
* The :command:`write_basic_package_version_file` understands a new
|
||||
``SameMinorVersion`` option for the ``COMPATIBILITY`` argument.
|
50
Modules/BasicConfigVersion-SameMinorVersion.cmake.in
Normal file
50
Modules/BasicConfigVersion-SameMinorVersion.cmake.in
Normal file
@ -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()
|
@ -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.
|
||||
#
|
||||
|
@ -11,7 +11,7 @@
|
||||
#
|
||||
# WRITE_BASIC_CONFIG_VERSION_FILE( filename
|
||||
# [VERSION major.minor.patch]
|
||||
# COMPATIBILITY (AnyNewerVersion|SameMajorVersion)
|
||||
# COMPATIBILITY (AnyNewerVersion|SameMajorVersion|SameMinorVersion|ExactVersion)
|
||||
# )
|
||||
#
|
||||
#
|
||||
|
@ -565,6 +565,84 @@ endif()
|
||||
|
||||
#######################
|
||||
|
||||
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/Zot123ConfigVersion.cmake
|
||||
VERSION 1.2.3.17
|
||||
COMPATIBILITY SameMinorVersion)
|
||||
|
||||
unset(PACKAGE_VERSION_UNSUITABLE)
|
||||
set(PACKAGE_VERSION_EXACT FALSE)
|
||||
set(PACKAGE_FIND_VERSION 2.3.4)
|
||||
set(PACKAGE_FIND_VERSION_MAJOR 2)
|
||||
set(PACKAGE_FIND_VERSION_MINOR 3)
|
||||
include(${CMAKE_CURRENT_BINARY_DIR}/Zot123ConfigVersion.cmake)
|
||||
if(PACKAGE_VERSION_COMPATIBLE)
|
||||
message(SEND_ERROR "Found Zot123 with version 1.2.3.17, but 2.3.4 was requested !")
|
||||
endif()
|
||||
if(PACKAGE_VERSION_EXACT)
|
||||
message(SEND_ERROR "PACKAGE_VERSION_EXACT set, although it should not be !")
|
||||
endif()
|
||||
|
||||
set(PACKAGE_FIND_VERSION 0.0.1)
|
||||
set(PACKAGE_FIND_VERSION_MAJOR 0)
|
||||
set(PACKAGE_FIND_VERSION_MINOR 0)
|
||||
include(${CMAKE_CURRENT_BINARY_DIR}/Zot123ConfigVersion.cmake)
|
||||
if(PACKAGE_VERSION_COMPATIBLE)
|
||||
message(SEND_ERROR "Found Zot123 with version 1.2.3.17, but 0.0.1 was requested !")
|
||||
endif()
|
||||
if(PACKAGE_VERSION_EXACT)
|
||||
message(SEND_ERROR "PACKAGE_VERSION_EXACT set, although it should not be !")
|
||||
endif()
|
||||
|
||||
set(PACKAGE_FIND_VERSION 1.0.0)
|
||||
set(PACKAGE_FIND_VERSION_MAJOR 1)
|
||||
set(PACKAGE_FIND_VERSION_MINOR 0)
|
||||
include(${CMAKE_CURRENT_BINARY_DIR}/Zot123ConfigVersion.cmake)
|
||||
if(PACKAGE_VERSION_COMPATIBLE)
|
||||
message(SEND_ERROR "Found Zot123 with version 1.2.3.17 (1.0.0 was requested) !")
|
||||
endif()
|
||||
if(PACKAGE_VERSION_EXACT)
|
||||
message(SEND_ERROR "PACKAGE_VERSION_EXACT set, although it should not be !")
|
||||
endif()
|
||||
|
||||
set(PACKAGE_FIND_VERSION 1.2.0)
|
||||
set(PACKAGE_FIND_VERSION_MAJOR 1)
|
||||
set(PACKAGE_FIND_VERSION_MINOR 2)
|
||||
include(${CMAKE_CURRENT_BINARY_DIR}/Zot123ConfigVersion.cmake)
|
||||
if(NOT PACKAGE_VERSION_COMPATIBLE)
|
||||
message(SEND_ERROR "Did not find Zot123 with version 1.2.3.17 (1.2.0 was requested) !")
|
||||
endif()
|
||||
if(PACKAGE_VERSION_EXACT)
|
||||
message(SEND_ERROR "PACKAGE_VERSION_EXACT set, although it should not be !")
|
||||
endif()
|
||||
|
||||
set(PACKAGE_FIND_VERSION 1.2.3)
|
||||
set(PACKAGE_FIND_VERSION_MAJOR 1)
|
||||
set(PACKAGE_FIND_VERSION_MINOR 2)
|
||||
include(${CMAKE_CURRENT_BINARY_DIR}/Zot123ConfigVersion.cmake)
|
||||
if(NOT PACKAGE_VERSION_COMPATIBLE)
|
||||
message(SEND_ERROR "Did not find Zot123 with version 1.2.3.17 (1.2.3 was requested) !")
|
||||
endif()
|
||||
if(PACKAGE_VERSION_EXACT)
|
||||
message(SEND_ERROR "PACKAGE_VERSION_EXACT set, although it should not be !")
|
||||
endif()
|
||||
|
||||
set(PACKAGE_FIND_VERSION 1.2.3.17)
|
||||
set(PACKAGE_FIND_VERSION_MAJOR 1)
|
||||
set(PACKAGE_FIND_VERSION_MINOR 2)
|
||||
include(${CMAKE_CURRENT_BINARY_DIR}/Zot123ConfigVersion.cmake)
|
||||
if(NOT PACKAGE_VERSION_COMPATIBLE)
|
||||
message(SEND_ERROR "Did not find Zot123 with version 1.2.3.17 (1.2.3.17 was requested) !")
|
||||
endif()
|
||||
if(NOT PACKAGE_VERSION_EXACT)
|
||||
message(SEND_ERROR "PACKAGE_VERSION_EXACT not set, although it should be !")
|
||||
endif()
|
||||
|
||||
if(PACKAGE_VERSION_UNSUITABLE)
|
||||
message(SEND_ERROR "PACKAGE_VERSION_UNSUITABLE set, but must not be !")
|
||||
endif()
|
||||
|
||||
#######################
|
||||
|
||||
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/Bar123ConfigVersion.cmake
|
||||
VERSION 1.2.3.17
|
||||
COMPATIBILITY ExactVersion)
|
||||
@ -618,7 +696,6 @@ if(PACKAGE_VERSION_EXACT)
|
||||
message(SEND_ERROR "PACKAGE_VERSION_EXACT set, although it should not be !")
|
||||
endif()
|
||||
|
||||
|
||||
set(PACKAGE_FIND_VERSION 1.2.3.17)
|
||||
set(PACKAGE_VERSION_EXACT FALSE)
|
||||
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
||||
|
Loading…
x
Reference in New Issue
Block a user