diff options
author | Alex Neundorf <neundorf@kde.org> | 2012-03-10 15:05:19 (GMT) |
---|---|---|
committer | Alex Neundorf <neundorf@kde.org> | 2012-03-10 15:10:52 (GMT) |
commit | 5d1822391765f1466a07884810919c8549556e0a (patch) | |
tree | 6369ced384510ba66f9b24289e42b49979c2894d /Modules/BasicConfigVersion-ExactVersion.cmake.in | |
parent | 1c69cd8febb41c45d4269d6fef24277a60ed3733 (diff) | |
download | CMake-5d1822391765f1466a07884810919c8549556e0a.zip CMake-5d1822391765f1466a07884810919c8549556e0a.tar.gz CMake-5d1822391765f1466a07884810919c8549556e0a.tar.bz2 |
write_basic_package_version_file: add ExactVersion mode
This mode is for packages which consider themselves only compatible if
exactly the same version is requested. The tweak version is ignored.
Alex
Diffstat (limited to 'Modules/BasicConfigVersion-ExactVersion.cmake.in')
-rw-r--r-- | Modules/BasicConfigVersion-ExactVersion.cmake.in | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/Modules/BasicConfigVersion-ExactVersion.cmake.in b/Modules/BasicConfigVersion-ExactVersion.cmake.in new file mode 100644 index 0000000..c610baa --- /dev/null +++ b/Modules/BasicConfigVersion-ExactVersion.cmake.in @@ -0,0 +1,42 @@ +# 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 equal to the requested version. +# The tweak version component is ignored. +# The variable CVF_VERSION must be set before calling configure_file(). + + +set(PACKAGE_VERSION "@CVF_VERSION@") + +if("@CVF_VERSION@" MATCHES "^([0-9]+\\.[0-9]+\\.[0-9]+)\\..*") # strip the tweak version + set(CVF_VERSION_NO_TWEAK "${CMAKE_MATCH_1}") +else() + set(CVF_VERSION_NO_TWEAK "@CVF_VERSION@") +endif() + +if("${PACKAGE_FIND_VERSION}" MATCHES "^([0-9]+\\.[0-9]+\\.[0-9]+)\\..*") # strip the tweak version + set(REQUESTED_VERSION_NO_TWEAK "${CMAKE_MATCH_1}") +else() + set(REQUESTED_VERSION_NO_TWEAK "${PACKAGE_FIND_VERSION}") +endif() + +if("${REQUESTED_VERSION_NO_TWEAK}" STREQUAL "${CVF_VERSION_NO_TWEAK}") + 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() + + +# 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() |