From f4581c2b13c07cbffa870f596345150668542a49 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Fri, 1 May 2020 15:00:35 +0200 Subject: [PATCH] Add CGALConfigVersion.cmake, and CTest tests --- CGALConfigVersion.cmake | 1 + Installation/CGALConfigVersion.cmake | 1 + .../lib/cmake/CGAL/CGALConfigVersion.cmake | 21 ++++++++++++ Installation/test/Installation/CMakeLists.txt | 34 +++++++++++++++++++ .../Installation/test_find_package.cmake.in | 14 ++++++++ 5 files changed, 71 insertions(+) create mode 100644 CGALConfigVersion.cmake create mode 100644 Installation/CGALConfigVersion.cmake create mode 100644 Installation/lib/cmake/CGAL/CGALConfigVersion.cmake create mode 100644 Installation/test/Installation/test_find_package.cmake.in diff --git a/CGALConfigVersion.cmake b/CGALConfigVersion.cmake new file mode 100644 index 00000000000..f1363d9a8f6 --- /dev/null +++ b/CGALConfigVersion.cmake @@ -0,0 +1 @@ +include(${CMAKE_CURRENT_LIST_DIR}/Installation/lib/cmake/CGAL/CGALConfigVersion.cmake) diff --git a/Installation/CGALConfigVersion.cmake b/Installation/CGALConfigVersion.cmake new file mode 100644 index 00000000000..9b0b10600b1 --- /dev/null +++ b/Installation/CGALConfigVersion.cmake @@ -0,0 +1 @@ +include(${CMAKE_CURRENT_LIST_DIR}/lib/cmake/CGAL/CGALConfigVersion.cmake) diff --git a/Installation/lib/cmake/CGAL/CGALConfigVersion.cmake b/Installation/lib/cmake/CGAL/CGALConfigVersion.cmake new file mode 100644 index 00000000000..77b73b21be0 --- /dev/null +++ b/Installation/lib/cmake/CGAL/CGALConfigVersion.cmake @@ -0,0 +1,21 @@ +set(CGAL_MAJOR_VERSION 4) +set(CGAL_MINOR_VERSION 14) +set(CGAL_BUGFIX_VERSION 4) +set(CGAL_VERSION_PUBLIC_RELEASE_NAME "CGAL-4.14.4") + +if (CGAL_BUGFIX_VERSION AND CGAL_BUGFIX_VERSION GREATER 0) + set(CGAL_CREATED_VERSION_NUM "${CGAL_MAJOR_VERSION}.${CGAL_MINOR_VERSION}.${CGAL_BUGFIX_VERSION}") +else() + set(CGAL_CREATED_VERSION_NUM "${CGAL_MAJOR_VERSION}.${CGAL_MINOR_VERSION}") +endif() + +set(PACKAGE_VERSION ${CGAL_CREATED_VERSION_NUM}) + +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() diff --git a/Installation/test/Installation/CMakeLists.txt b/Installation/test/Installation/CMakeLists.txt index 1c0af2324dd..64aa39edf93 100644 --- a/Installation/test/Installation/CMakeLists.txt +++ b/Installation/test/Installation/CMakeLists.txt @@ -102,3 +102,37 @@ else() message(STATUS "NOTICE: This program requires the CGAL library, and will not be compiled.") endif() + +function(CGAL_installation_test_find_package_version mode) + set(EXACT) + if(mode STREQUAL "less") + MATH(EXPR CGAL_MAJOR_VERSION "${CGAL_MAJOR_VERSION} - 1") + endif() + if(mode STREQUAL "greater" OR mode STREQUAL "fail-exact") + MATH(EXPR CGAL_MINOR_VERSION "${CGAL_MINOR_VERSION} + 1") + endif() + if(mode STREQUAL "exact" OR mode STREQUAL "fail-exact") + set(EXACT "EXACT ") + endif() + if (CGAL_BUGFIX_VERSION AND CGAL_BUGFIX_VERSION GREATER 0) + set(VERSION "${CGAL_MAJOR_VERSION}.${CGAL_MINOR_VERSION}.${CGAL_BUGFIX_VERSION}") + else() + set(VERSION "${CGAL_MAJOR_VERSION}.${CGAL_MINOR_VERSION}") + endif() + file(REMOVE_RECURSE "${CMAKE_CURRENT_BINARY_DIR}/build-test_find_package_version_${mode}") + file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/build-test_find_package_version_${mode}) + file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/test_find_package_version_${mode}) + configure_file(test_find_package.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/test_find_package_version_${mode}/CMakeLists.txt) + add_test(NAME test_find_package_version_${mode} + COMMAND ${CMAKE_COMMAND} -S ${CMAKE_CURRENT_BINARY_DIR}/test_find_package_version_${mode} -B ${CMAKE_CURRENT_BINARY_DIR}/build-test_find_package_version_${mode}) +endfunction() + +CGAL_installation_test_find_package_version(less) +CGAL_installation_test_find_package_version(equal) +CGAL_installation_test_find_package_version(greater) +CGAL_installation_test_find_package_version(exact) +CGAL_installation_test_find_package_version(fail-exact) +set_tests_properties( + test_find_package_version_greater + test_find_package_version_fail-exact + PROPERTIES WILL_FAIL TRUE) diff --git a/Installation/test/Installation/test_find_package.cmake.in b/Installation/test/Installation/test_find_package.cmake.in new file mode 100644 index 00000000000..fc7152ef4d4 --- /dev/null +++ b/Installation/test/Installation/test_find_package.cmake.in @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION ${CMAKE_VERSION}) +project( test_find_package_${mode} ) +find_package(CGAL ${VERSION} ${EXACT}REQUIRED + PATHS ${CGAL_DIR} + NO_DEFAULT_PATH + NO_PACKAGE_ROOT_PATH + NO_CMAKE_PATH + NO_CMAKE_ENVIRONMENT_PATH + NO_SYSTEM_ENVIRONMENT_PATH + NO_CMAKE_PACKAGE_REGISTRY + NO_CMAKE_BUILDS_PATH + NO_CMAKE_SYSTEM_PATH + NO_CMAKE_SYSTEM_PACKAGE_REGISTRY + )