summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Neundorf <neundorf@kde.org>2011-08-01 21:29:27 (GMT)
committerAlex Neundorf <neundorf@kde.org>2011-08-01 21:29:27 (GMT)
commit4ba09bc6a22ab9aa3f59b6804224e3f96159658d (patch)
tree025446a29a3d7a13ffee266bb563ebe2b659373a
parent02b1e4b96a10b77e40dbc7f5e5d23ccd61a2b08b (diff)
downloadCMake-4ba09bc6a22ab9aa3f59b6804224e3f96159658d.zip
CMake-4ba09bc6a22ab9aa3f59b6804224e3f96159658d.tar.gz
CMake-4ba09bc6a22ab9aa3f59b6804224e3f96159658d.tar.bz2
Add some tests for write_basic_config_version_file()
Alex
-rw-r--r--Modules/BasicConfigVersion-AnyNewerVersion.cmake.in2
-rw-r--r--Modules/BasicConfigVersion-SameMajorVersion.cmake.in2
-rw-r--r--Tests/FindPackageTest/CMakeLists.txt80
3 files changed, 84 insertions, 0 deletions
diff --git a/Modules/BasicConfigVersion-AnyNewerVersion.cmake.in b/Modules/BasicConfigVersion-AnyNewerVersion.cmake.in
index 600deb1..30749c4 100644
--- a/Modules/BasicConfigVersion-AnyNewerVersion.cmake.in
+++ b/Modules/BasicConfigVersion-AnyNewerVersion.cmake.in
@@ -10,6 +10,8 @@
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")
diff --git a/Modules/BasicConfigVersion-SameMajorVersion.cmake.in b/Modules/BasicConfigVersion-SameMajorVersion.cmake.in
index b41ffba..f633ee8 100644
--- a/Modules/BasicConfigVersion-SameMajorVersion.cmake.in
+++ b/Modules/BasicConfigVersion-SameMajorVersion.cmake.in
@@ -12,6 +12,8 @@
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")
diff --git a/Tests/FindPackageTest/CMakeLists.txt b/Tests/FindPackageTest/CMakeLists.txt
index 0169ac9..ca64440 100644
--- a/Tests/FindPackageTest/CMakeLists.txt
+++ b/Tests/FindPackageTest/CMakeLists.txt
@@ -303,3 +303,83 @@ SET(CMakeTestExportPackage_DIR "" CACHE FILEPATH
"Wipe out find results for testing." FORCE)
STRING(REGEX REPLACE "-.*$" "" version ${CMAKE_VERSION})
FIND_PACKAGE(CMakeTestExportPackage 1.${version} EXACT REQUIRED)
+
+#-----------------------------------------------------------------------------
+# Test write_basic_config_version_file().
+
+include(WriteBasicConfigVersionFile)
+
+write_basic_config_version_file(${CMAKE_CURRENT_BINARY_DIR}/Foo123ConfigVersion.cmake
+ VERSION 1.2.3
+ COMPATIBILITY AnyNewerVersion)
+
+set(PACKAGE_FIND_VERSION 2.3.4)
+include(${CMAKE_CURRENT_BINARY_DIR}/Foo123ConfigVersion.cmake)
+if(PACKAGE_VERSION_COMPATIBLE)
+ message(SEND_ERROR "Found Foo123 with version 1.2.3, but 2.3.4 was requested !")
+endif()
+
+set(PACKAGE_FIND_VERSION 0.0.1)
+include(${CMAKE_CURRENT_BINARY_DIR}/Foo123ConfigVersion.cmake)
+if(NOT PACKAGE_VERSION_COMPATIBLE)
+ message(SEND_ERROR "Did not find Foo123 with version 1.2.3 (0.0.1 was requested) !")
+endif()
+
+set(PACKAGE_FIND_VERSION 1.0.0)
+include(${CMAKE_CURRENT_BINARY_DIR}/Foo123ConfigVersion.cmake)
+if(NOT PACKAGE_VERSION_COMPATIBLE)
+ message(SEND_ERROR "Did not find Foo123 with version 1.2.3 (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.3)
+include(${CMAKE_CURRENT_BINARY_DIR}/Foo123ConfigVersion.cmake)
+if(NOT PACKAGE_VERSION_COMPATIBLE)
+ message(SEND_ERROR "Did not find Foo123 with version 1.2.3 (1.2.3 was requested) !")
+endif()
+if(NOT PACKAGE_VERSION_EXACT)
+ message(SEND_ERROR "PACKAGE_VERSION_EXACT not set, although it should be !")
+endif()
+
+
+#######################
+
+write_basic_config_version_file(${CMAKE_CURRENT_BINARY_DIR}/Boo123ConfigVersion.cmake
+ VERSION 1.2.3
+ COMPATIBILITY SameMajorVersion)
+
+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()
+
+set(PACKAGE_FIND_VERSION 0.0.1)
+set(PACKAGE_FIND_VERSION_MAJOR 0)
+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()
+
+set(PACKAGE_FIND_VERSION 1.0.0)
+set(PACKAGE_FIND_VERSION_MAJOR 1)
+include(${CMAKE_CURRENT_BINARY_DIR}/Boo123ConfigVersion.cmake)
+if(NOT PACKAGE_VERSION_COMPATIBLE)
+ message(SEND_ERROR "Did not find Boo123 with version 1.2.3 (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.3)
+set(PACKAGE_FIND_VERSION_MAJOR 1)
+include(${CMAKE_CURRENT_BINARY_DIR}/Boo123ConfigVersion.cmake)
+if(NOT PACKAGE_VERSION_COMPATIBLE)
+ message(SEND_ERROR "Did not find Boo123 with version 1.2.3 (1.2.3 was requested) !")
+endif()
+if(NOT PACKAGE_VERSION_EXACT)
+ message(SEND_ERROR "PACKAGE_VERSION_EXACT not set, although it should be !")
+endif()