diff options
author | Rolf Eike Beer <eike@sf-mail.de> | 2012-10-24 17:55:14 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2012-10-31 20:22:42 (GMT) |
commit | d1f3bfe50ecf974c313d0e191475bc4ea18f0c9c (patch) | |
tree | 406f85dc84adb659f76425b49fdd47957b1c058e /Tests/CMakeOnly/MajorVersionSelection | |
parent | f551fa62450379b41b510054948e097582538357 (diff) | |
download | CMake-d1f3bfe50ecf974c313d0e191475bc4ea18f0c9c.zip CMake-d1f3bfe50ecf974c313d0e191475bc4ea18f0c9c.tar.gz CMake-d1f3bfe50ecf974c313d0e191475bc4ea18f0c9c.tar.bz2 |
Tests: add MajorVersionSelection tests
For things where we may have 2 major versions of the same software
installed in parallel (think of Qt and Python) make sure our version
selection gets this right.
Diffstat (limited to 'Tests/CMakeOnly/MajorVersionSelection')
-rw-r--r-- | Tests/CMakeOnly/MajorVersionSelection/CMakeLists.txt | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/Tests/CMakeOnly/MajorVersionSelection/CMakeLists.txt b/Tests/CMakeOnly/MajorVersionSelection/CMakeLists.txt new file mode 100644 index 0000000..74f5451 --- /dev/null +++ b/Tests/CMakeOnly/MajorVersionSelection/CMakeLists.txt @@ -0,0 +1,46 @@ +cmake_minimum_required(VERSION 2.8) + +if (NOT MAJOR_TEST_MODULE OR NOT MAJOR_TEST_VERSION) + message(FATAL_ERROR "test selection variables not set up") +endif () + +if (MAJOR_TEST_NO_LANGUAGES) + project(major_detect_${MAJOR_TEST_MODULE}_${MAJOR_TEST_VERSION} NONE) +else () + project(major_detect_${MAJOR_TEST_MODULE}_${MAJOR_TEST_VERSION}) +endif () + +find_package(${MAJOR_TEST_MODULE} ${MAJOR_TEST_VERSION}) + +if (MAJOR_TEST_VERSION_VAR) + set(VERSION_VAR "${MAJOR_TEST_VERSION_VAR}") +else () + set(VERSION_VAR "${MAJOR_TEST_MODULE}_VERSION_STRING") +endif () + +string(TOUPPER "${MAJOR_TEST_MODULE}" MODULE_UPPER) + +if ( ( ${MAJOR_TEST_MODULE}_FOUND OR ${MODULE_UPPER}_FOUND ) AND "${VERSION_VAR}") + message(STATUS "${VERSION_VAR} is '${${VERSION_VAR}}'") + if ("${VERSION_VAR}" VERSION_LESS MAJOR_TEST_VERSION) + message(SEND_ERROR "Found version ${${VERSION_VAR}} is less than requested major version ${MAJOR_TEST_VERSION}") + endif () + math(EXPR V_PLUS_ONE "${MAJOR_TEST_VERSION} + 1") + if ("${VERSION_VAR}" VERSION_GREATER V_PLUS_ONE) + message(SEND_ERROR "Found version ${${VERSION_VAR}} is greater than requested major version ${MAJOR_TEST_VERSION}") + endif () +endif () + +if ( ( ${MAJOR_TEST_MODULE}_FOUND OR ${MODULE_UPPER}_FOUND ) AND ${MAJOR_TEST_MODULE}_VERSION_MAJOR) + message(STATUS "${MAJOR_TEST_MODULE}_VERSION_MAJOR is '${${MAJOR_TEST_MODULE}_VERSION_MAJOR}'") + if (NOT ${MAJOR_TEST_VERSION} EQUAL ${MAJOR_TEST_MODULE}_VERSION_MAJOR) + message(SEND_ERROR "We requested major version ${MAJOR_TEST_VERSION} but ${MAJOR_TEST_MODULE} set ${MAJOR_TEST_MODULE}_VERSION_MAJOR to ${${MAJOR_TEST_MODULE}_VERSION_MAJOR}") + endif () +endif () + +if ( ( ${MAJOR_TEST_MODULE}_FOUND OR ${MODULE_UPPER}_FOUND ) AND ${MODULE_UPPER}_VERSION_MAJOR) + message(STATUS "${MODULE_UPPER}_VERSION_MAJOR is '${${MODULE_UPPER}_VERSION_MAJOR}'") + if (NOT ${MAJOR_TEST_VERSION} EQUAL ${MODULE_UPPER}_VERSION_MAJOR) + message(SEND_ERROR "We requested major version ${MAJOR_TEST_VERSION} but ${MAJOR_TEST_MODULE} set ${MODULE_UPPER}_VERSION_MAJOR to ${${MODULE_UPPER}_VERSION_MAJOR}") + endif () +endif () |