Avoid CMake errors with CMake<=3.4

This commit is contained in:
Laurent Rineau 2017-10-31 13:06:16 +01:00
parent 42052eea86
commit 39cb35b134
3 changed files with 29 additions and 10 deletions

View File

@ -156,18 +156,22 @@ function(cgal_arr_2_add_target exe_name source_file)
target_compile_options(${name} PRIVATE ${flags})
cgal_debug_message(STATUS "# -> target ${name} with TESTSUITE_CXXFLAGS: ${flags}")
add_test(NAME "compilation_of__${name}"
COMMAND ${TIME_COMMAND} "${CMAKE_COMMAND}" --build "${CMAKE_BINARY_DIR}" --target "${name}")
set_property(TEST "compilation_of__${name}"
APPEND PROPERTY LABELS "${PROJECT_NAME}")
if(BUILD_TESTING)
add_test(NAME "compilation_of__${name}"
COMMAND ${TIME_COMMAND} "${CMAKE_COMMAND}" --build "${CMAKE_BINARY_DIR}" --target "${name}")
set_property(TEST "compilation_of__${name}"
APPEND PROPERTY LABELS "${PROJECT_NAME}")
endif(BUILD_TESTING)
# Add a compatibility-mode with the shell script `cgal_test_base`
if(NOT TARGET ${exe_name})
create_single_source_cgal_program( "${source_file}" NO_TESTING)
add_test(NAME "compilation_of__${exe_name}"
COMMAND ${TIME_COMMAND} "${CMAKE_COMMAND}" --build "${CMAKE_BINARY_DIR}" --target "${exe_name}")
set_property(TEST "compilation_of__${exe_name}"
APPEND PROPERTY LABELS "${PROJECT_NAME}")
if(BUILD_TESTING)
add_test(NAME "compilation_of__${exe_name}"
COMMAND ${TIME_COMMAND} "${CMAKE_COMMAND}" --build "${CMAKE_BINARY_DIR}" --target "${exe_name}")
set_property(TEST "compilation_of__${exe_name}"
APPEND PROPERTY LABELS "${PROJECT_NAME}")
endif(BUILD_TESTING)
endif()
endfunction()
@ -180,11 +184,17 @@ endfunction()
function(run_test_with_flags)
# ${ARGV0} - executable name
# ${ARGV1} - test substring name
if(NOT BUILD_TESTING)
return()
endif()
cgal_debug_message(STATUS "# run_test_with_flags(${ARGN})")
cgal_add_test(${ARGV0}_${suffix} ${ARGV0} ${ARGV0}.${ARGV1})
endfunction()
function(run_test_alt name datafile)
if(NOT BUILD_TESTING)
return()
endif()
if(suffix)
set(name ${name}_${suffix})
endif()
@ -220,7 +230,9 @@ function(compile_and_run)
cgal_debug_message(STATUS "# compile_and_run(${ARGN})")
# message(" successful compilation of ${name}")
cgal_arr_2_add_target(${name} ${name}.cpp)
cgal_add_test(${name})
if(BUILD_TESTING)
cgal_add_test(${name})
endif()
endfunction()
function(execute_commands_old_structure data_dir traits_type_name)

View File

@ -17,6 +17,10 @@ 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()
# and finally start actual build
add_subdirectory( Installation )

View File

@ -135,7 +135,10 @@ 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()
endif (CGAL_BRANCH_BUILD )
#message(STATUS "Packages found: ${CGAL_CONFIGURED_PACKAGES}")