Replace include(CTest) by minimal usage

- Define the option `BUILD_TESTING`
- Call to `enable_testing()` if `BUILD_TESTING` is on.
This commit is contained in:
Laurent Rineau 2019-02-04 15:30:24 +01:00
parent e42cc50e7d
commit 02690350ee
3 changed files with 11 additions and 3 deletions

View File

@ -37,11 +37,13 @@ message( "== CMake setup (DONE) ==\n" )
# Enable testing with BUILD_TESTING
option(BUILD_TESTING "Build the testing tree." OFF)
include(CTest)
if(BUILD_TESTING AND NOT POLICY CMP0064)
message(FATAL_ERROR "CGAL support of CTest requires CMake version 3.4 or later.
The variable BUILD_TESTING must be set of OFF.")
endif()
if(BUILD_TESTING)
enable_testing()
endif()
# and finally start actual build
add_subdirectory( Installation )

View File

@ -108,11 +108,13 @@ else ( CGAL_BRANCH_BUILD )
# Enable testing with BUILD_TESTING
option(BUILD_TESTING "Build the testing tree." OFF)
include(CTest)
if(BUILD_TESTING AND NOT POLICY CMP0064)
message(FATAL_ERROR "CGAL support of CTest requires CMake version 3.4 or later.
The variable BUILD_TESTING must be set of OFF.")
endif()
if(BUILD_TESTING)
enable_testing()
endif()
endif (CGAL_BRANCH_BUILD )
#message(STATUS "Packages found: ${CGAL_CONFIGURED_PACKAGES}")

View File

@ -3,6 +3,8 @@ if(CGAL_add_test_included)
endif(CGAL_add_test_included)
set(CGAL_add_test_included TRUE)
option(BUILD_TESTING "Build the testing tree." OFF)
if(NOT POLICY CMP0064)
# CMake <= 3.3
if(BUILD_TESTING)
@ -19,7 +21,9 @@ if(NOT POLICY CMP0064)
return()
endif()
include(CTest)
if(BUILD_TESTING)
enable_testing()
endif()
cmake_policy(SET CMP0064 NEW)