Skip to content

Commit

Permalink
Add CGALConfigVersion.cmake, and CTest tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lrineau committed May 1, 2020
1 parent c6df90f commit f4581c2
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 0 deletions.
1 change: 1 addition & 0 deletions CGALConfigVersion.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include(${CMAKE_CURRENT_LIST_DIR}/Installation/lib/cmake/CGAL/CGALConfigVersion.cmake)
1 change: 1 addition & 0 deletions Installation/CGALConfigVersion.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include(${CMAKE_CURRENT_LIST_DIR}/lib/cmake/CGAL/CGALConfigVersion.cmake)
21 changes: 21 additions & 0 deletions Installation/lib/cmake/CGAL/CGALConfigVersion.cmake
Original file line number Diff line number Diff line change
@@ -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()
34 changes: 34 additions & 0 deletions Installation/test/Installation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
14 changes: 14 additions & 0 deletions Installation/test/Installation/test_find_package.cmake.in
Original file line number Diff line number Diff line change
@@ -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
)

0 comments on commit f4581c2

Please sign in to comment.