diff options
author | Brad King <brad.king@kitware.com> | 2008-01-29 01:38:48 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2008-01-29 01:38:48 (GMT) |
commit | 41c2895b7524cc4dc60225044a6bba99e0c048ab (patch) | |
tree | 55c46e2b65be4069f3f7d4a01646df32d67af0b1 /Tests/FindPackageTest | |
parent | 404db8811e4d6dc8ed89f4b1e3efafbb5985dc44 (diff) | |
download | CMake-41c2895b7524cc4dc60225044a6bba99e0c048ab.zip CMake-41c2895b7524cc4dc60225044a6bba99e0c048ab.tar.gz CMake-41c2895b7524cc4dc60225044a6bba99e0c048ab.tar.bz2 |
ENH: Added version support to Config mode of find_package command.
- Added EXACT option to request an exact version.
- Enforce version using check provided by package.
- Updated FindPackageTest to test versioning in config mode.
Diffstat (limited to 'Tests/FindPackageTest')
9 files changed, 77 insertions, 1 deletions
diff --git a/Tests/FindPackageTest/CMakeLists.txt b/Tests/FindPackageTest/CMakeLists.txt index 8b3225e..2925db0 100644 --- a/Tests/FindPackageTest/CMakeLists.txt +++ b/Tests/FindPackageTest/CMakeLists.txt @@ -32,7 +32,10 @@ FIND_PACKAGE(VersionTestC 1.2.3) #SET(CMAKE_FIND_DEBUG_MODE 1) # For purposes of the test wipe out previous find results. -SET(PACKAGES foo Foo Bar TFramework Tframework TApp Tapp Special) +SET(PACKAGES + foo Foo Bar TFramework Tframework TApp Tapp Special + VersionedA VersionedB + ) FOREACH(p ${PACKAGES}) SET(${p}_DIR "" CACHE FILEPATH "Wipe out find results for testing." FORCE) ENDFOREACH(p) @@ -51,6 +54,8 @@ FIND_PACKAGE(Tframework) FIND_PACKAGE(TApp) FIND_PACKAGE(Tapp CONFIGS tapp-config.cmake) FIND_PACKAGE(Special NAMES Suffix SuffixTest PATH_SUFFIXES test) +FIND_PACKAGE(VersionedA 2 NAMES zot) +FIND_PACKAGE(VersionedB 3.1 EXACT NAMES zot) # Expected locations at which packages should be found. SET(foo_EXPECTED "lib/foo-1.2/foo-config.cmake") @@ -65,6 +70,8 @@ SET(TApp_EXPECTED "TApp.app/Contents/Resources/TAppConfig.cmake") SET(Tapp_EXPECTED "TApp.app/Contents/Resources/cmake/tapp-config.cmake") +SET(VersionedA_EXPECTED "lib/zot-2.0/zot-config.cmake") +SET(VersionedB_EXPECTED "lib/zot-3.1/zot-config.cmake") # Check the results. FOREACH(p ${PACKAGES}) @@ -88,3 +95,43 @@ FOREACH(p ${PACKAGES}) MESSAGE(SEND_ERROR "Package ${p} not found!") ENDIF(${p}_FOUND) ENDFOREACH(p) + +# Check that version information was extracted. +IF(NOT "${VersionedA_VERSION}" STREQUAL "2.0") + MESSAGE(SEND_ERROR + "Package VersionedA is version [${VersionedA_VERSION}], not [2.0]") +ENDIF(NOT "${VersionedA_VERSION}" STREQUAL "2.0") +IF(NOT "${VersionedA_VERSION_MAJOR}" STREQUAL "2") + MESSAGE(SEND_ERROR + "Package VersionedA is major version [${VersionedA_VERSION_MAJOR}], not [2]") +ENDIF(NOT "${VersionedA_VERSION_MAJOR}" STREQUAL "2") +IF(NOT "${VersionedA_VERSION_MINOR}" STREQUAL "0") + MESSAGE(SEND_ERROR + "Package VersionedA is minor version [${VersionedA_VERSION_MINOR}], not [0]") +ENDIF(NOT "${VersionedA_VERSION_MINOR}" STREQUAL "0") + +IF(NOT "${VersionedB_VERSION}" STREQUAL "3.1") + MESSAGE(SEND_ERROR + "Package VersionedB is version [${VersionedB_VERSION}], not [3.1]") +ENDIF(NOT "${VersionedB_VERSION}" STREQUAL "3.1") +IF(NOT "${VersionedB_VERSION_MAJOR}" STREQUAL "3") + MESSAGE(SEND_ERROR + "Package VersionedB is major version [${VersionedB_VERSION_MAJOR}], not [3]") +ENDIF(NOT "${VersionedB_VERSION_MAJOR}" STREQUAL "3") +IF(NOT "${VersionedB_VERSION_MINOR}" STREQUAL "1") + MESSAGE(SEND_ERROR + "Package VersionedB is minor version [${VersionedB_VERSION_MINOR}], not [1]") +ENDIF(NOT "${VersionedB_VERSION_MINOR}" STREQUAL "1") + +IF(NOT "${Special_VERSION}" STREQUAL "1.2") + MESSAGE(SEND_ERROR + "Package Special is version [${Special_VERSION}], not [1.2]") +ENDIF(NOT "${Special_VERSION}" STREQUAL "1.2") +IF(NOT "${Special_VERSION_MAJOR}" STREQUAL "1") + MESSAGE(SEND_ERROR + "Package Special is major version [${Special_VERSION_MAJOR}], not [1]") +ENDIF(NOT "${Special_VERSION_MAJOR}" STREQUAL "1") +IF(NOT "${Special_VERSION_MINOR}" STREQUAL "2") + MESSAGE(SEND_ERROR + "Package Special is minor version [${Special_VERSION_MINOR}], not [2]") +ENDIF(NOT "${Special_VERSION_MINOR}" STREQUAL "2") diff --git a/Tests/FindPackageTest/lib/suffix/test/SuffixTestConfigVersion.cmake b/Tests/FindPackageTest/lib/suffix/test/SuffixTestConfigVersion.cmake new file mode 100644 index 0000000..5c3bdde --- /dev/null +++ b/Tests/FindPackageTest/lib/suffix/test/SuffixTestConfigVersion.cmake @@ -0,0 +1,7 @@ +SET(PACKAGE_VERSION 1.2) +IF("${PACKAGE_FIND_VERSION_MAJOR}" EQUAL 1) + SET(PACKAGE_VERSION_COMPATIBLE 1) + IF("${PACKAGE_FIND_VERSION_MINOR}" EQUAL 2) + SET(PACKAGE_VERSION_EXACT 1) + ENDIF("${PACKAGE_FIND_VERSION_MINOR}" EQUAL 2) +ENDIF("${PACKAGE_FIND_VERSION_MAJOR}" EQUAL 1) diff --git a/Tests/FindPackageTest/lib/zot-1.0/zot-config.cmake b/Tests/FindPackageTest/lib/zot-1.0/zot-config.cmake new file mode 100644 index 0000000..deffa57 --- /dev/null +++ b/Tests/FindPackageTest/lib/zot-1.0/zot-config.cmake @@ -0,0 +1 @@ +# Test config file. diff --git a/Tests/FindPackageTest/lib/zot-2.0/zot-config-version.cmake b/Tests/FindPackageTest/lib/zot-2.0/zot-config-version.cmake new file mode 100644 index 0000000..10ac53d --- /dev/null +++ b/Tests/FindPackageTest/lib/zot-2.0/zot-config-version.cmake @@ -0,0 +1,5 @@ +SET(PACKAGE_VERSION 2.0) +IF("${PACKAGE_FIND_VERSION_MAJOR}" EQUAL 2) + SET(PACKAGE_VERSION_COMPATIBLE 1) +ENDIF("${PACKAGE_FIND_VERSION_MAJOR}" EQUAL 2) + diff --git a/Tests/FindPackageTest/lib/zot-2.0/zot-config.cmake b/Tests/FindPackageTest/lib/zot-2.0/zot-config.cmake new file mode 100644 index 0000000..deffa57 --- /dev/null +++ b/Tests/FindPackageTest/lib/zot-2.0/zot-config.cmake @@ -0,0 +1 @@ +# Test config file. diff --git a/Tests/FindPackageTest/lib/zot-3.0/zot-config-version.cmake b/Tests/FindPackageTest/lib/zot-3.0/zot-config-version.cmake new file mode 100644 index 0000000..af57cfa --- /dev/null +++ b/Tests/FindPackageTest/lib/zot-3.0/zot-config-version.cmake @@ -0,0 +1,5 @@ +SET(PACKAGE_VERSION 3.0) +IF("${PACKAGE_FIND_VERSION_MAJOR}" EQUAL 3) + SET(PACKAGE_VERSION_COMPATIBLE 1) +ENDIF("${PACKAGE_FIND_VERSION_MAJOR}" EQUAL 3) + diff --git a/Tests/FindPackageTest/lib/zot-3.0/zot-config.cmake b/Tests/FindPackageTest/lib/zot-3.0/zot-config.cmake new file mode 100644 index 0000000..deffa57 --- /dev/null +++ b/Tests/FindPackageTest/lib/zot-3.0/zot-config.cmake @@ -0,0 +1 @@ +# Test config file. diff --git a/Tests/FindPackageTest/lib/zot-3.1/zot-config-version.cmake b/Tests/FindPackageTest/lib/zot-3.1/zot-config-version.cmake new file mode 100644 index 0000000..b54d94c --- /dev/null +++ b/Tests/FindPackageTest/lib/zot-3.1/zot-config-version.cmake @@ -0,0 +1,8 @@ +SET(PACKAGE_VERSION 3.1) +IF("${PACKAGE_FIND_VERSION_MAJOR}" EQUAL 3) + SET(PACKAGE_VERSION_COMPATIBLE 1) + IF("${PACKAGE_FIND_VERSION_MINOR}" EQUAL 1) + SET(PACKAGE_VERSION_EXACT 1) + ENDIF("${PACKAGE_FIND_VERSION_MINOR}" EQUAL 1) +ENDIF("${PACKAGE_FIND_VERSION_MAJOR}" EQUAL 3) + diff --git a/Tests/FindPackageTest/lib/zot-3.1/zot-config.cmake b/Tests/FindPackageTest/lib/zot-3.1/zot-config.cmake new file mode 100644 index 0000000..deffa57 --- /dev/null +++ b/Tests/FindPackageTest/lib/zot-3.1/zot-config.cmake @@ -0,0 +1 @@ +# Test config file. |