summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Modules/BasicConfigVersion-AnyNewerVersion.cmake.in24
-rw-r--r--Modules/BasicConfigVersion-SameMajorVersion.cmake.in45
-rw-r--r--Tests/FindPackageTest/CMakeLists.txt11
3 files changed, 42 insertions, 38 deletions
diff --git a/Modules/BasicConfigVersion-AnyNewerVersion.cmake.in b/Modules/BasicConfigVersion-AnyNewerVersion.cmake.in
index 30749c4..469bcdb 100644
--- a/Modules/BasicConfigVersion-AnyNewerVersion.cmake.in
+++ b/Modules/BasicConfigVersion-AnyNewerVersion.cmake.in
@@ -10,22 +10,18 @@
set(PACKAGE_VERSION "@CVF_VERSION@")
-set(PACKAGE_VERSION_EXACT FALSE) # initialize to FALSE
+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()
# 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_COMPATIBLE FALSE)
-else()
-
- 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() \ No newline at end of file
+ set(PACKAGE_VERSION_UNSUITABLE TRUE)
+endif()
diff --git a/Modules/BasicConfigVersion-SameMajorVersion.cmake.in b/Modules/BasicConfigVersion-SameMajorVersion.cmake.in
index f633ee8..8d091ea 100644
--- a/Modules/BasicConfigVersion-SameMajorVersion.cmake.in
+++ b/Modules/BasicConfigVersion-SameMajorVersion.cmake.in
@@ -12,34 +12,31 @@
set(PACKAGE_VERSION "@CVF_VERSION@")
-set(PACKAGE_VERSION_EXACT FALSE) # initialize to FALSE
-
-# 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_COMPATIBLE FALSE)
+if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
+ set(PACKAGE_VERSION_COMPATIBLE FALSE)
else()
- if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
- set(PACKAGE_VERSION_COMPATIBLE FALSE)
+ if("@CVF_VERSION@" MATCHES "^([0-9]+)\\.")
+ set(CVF_VERSION_MAJOR "${CMAKE_MATCH_1}")
else()
+ set(CVF_VERSION_MAJOR "@CVF_VERSION@")
+ endif()
- if("@CVF_VERSION@" MATCHES "^([0-9]+)\\.")
- set(CVF_VERSION_MAJOR "${CMAKE_MATCH_1}")
- else()
- set(CVF_VERSION_MAJOR "@CVF_VERSION@")
- 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}")
- set(PACKAGE_VERSION_EXACT TRUE)
- 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}")
+ set(PACKAGE_VERSION_EXACT TRUE)
+ endif()
+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/Tests/FindPackageTest/CMakeLists.txt b/Tests/FindPackageTest/CMakeLists.txt
index ca64440..9a4bdfe 100644
--- a/Tests/FindPackageTest/CMakeLists.txt
+++ b/Tests/FindPackageTest/CMakeLists.txt
@@ -350,12 +350,16 @@ write_basic_config_version_file(${CMAKE_CURRENT_BINARY_DIR}/Boo123ConfigVersion.
VERSION 1.2.3
COMPATIBILITY SameMajorVersion)
+set(PACKAGE_VERSION_EXACT FALSE)
set(PACKAGE_FIND_VERSION 2.3.4)
set(PACKAGE_FIND_VERSION_MAJOR 2)
include(${CMAKE_CURRENT_BINARY_DIR}/Boo123ConfigVersion.cmake)
if(PACKAGE_VERSION_COMPATIBLE)
message(SEND_ERROR "Found Boo123 with version 1.2.3, 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)
@@ -363,6 +367,9 @@ include(${CMAKE_CURRENT_BINARY_DIR}/Boo123ConfigVersion.cmake)
if(PACKAGE_VERSION_COMPATIBLE)
message(SEND_ERROR "Found Boo123 with version 1.2.3, 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)
@@ -383,3 +390,7 @@ 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()