From e390f87dd197c18e560fb7381f9dad8d15a31297 Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Sat, 10 Mar 2012 16:19:02 +0100 Subject: [PATCH] WriteBasicConfigVersionFile: add test for ExactVersion mode Alex --- Tests/FindPackageTest/CMakeLists.txt | 70 ++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/Tests/FindPackageTest/CMakeLists.txt b/Tests/FindPackageTest/CMakeLists.txt index a4f213b2b..73f24e0bd 100644 --- a/Tests/FindPackageTest/CMakeLists.txt +++ b/Tests/FindPackageTest/CMakeLists.txt @@ -421,3 +421,73 @@ 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) + +set(PACKAGE_VERSION_EXACT FALSE) +set(PACKAGE_FIND_VERSION 2.3.4) +include(${CMAKE_CURRENT_BINARY_DIR}/Bar123ConfigVersion.cmake) +if(PACKAGE_VERSION_COMPATIBLE) + message(SEND_ERROR "Found Bar123 with version 1.2.3 (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 1.2) +include(${CMAKE_CURRENT_BINARY_DIR}/Bar123ConfigVersion.cmake) +if(PACKAGE_VERSION_COMPATIBLE) + message(SEND_ERROR "Found Bar123 with version 1.2.3 (1.2 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) +include(${CMAKE_CURRENT_BINARY_DIR}/Bar123ConfigVersion.cmake) +if(PACKAGE_VERSION_COMPATIBLE) + message(SEND_ERROR "Found Bar123 with version 1.2.3 (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.2.3.4) +include(${CMAKE_CURRENT_BINARY_DIR}/Bar123ConfigVersion.cmake) +if(NOT PACKAGE_VERSION_COMPATIBLE) + message(SEND_ERROR "Did not find Bar123 with version 1.2.3 (1.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 1.2.3) +set(PACKAGE_VERSION_EXACT FALSE) +set(PACKAGE_VERSION_COMPATIBLE FALSE) +include(${CMAKE_CURRENT_BINARY_DIR}/Bar123ConfigVersion.cmake) +if(NOT PACKAGE_VERSION_COMPATIBLE) + message(SEND_ERROR "Did not find Bar123 with version 1.2.3 (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_VERSION_EXACT FALSE) +set(PACKAGE_VERSION_COMPATIBLE FALSE) +include(${CMAKE_CURRENT_BINARY_DIR}/Bar123ConfigVersion.cmake) +if(NOT PACKAGE_VERSION_COMPATIBLE) + message(SEND_ERROR "Did not find Bar123 with version 1.2.3 (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()