2015-11-05 19:36:26 +01:00
|
|
|
include(EigenTesting)
|
|
|
|
include(CheckCXXSourceCompiles)
|
|
|
|
|
2017-10-24 23:57:35 +02:00
|
|
|
# configure the "site" and "buildname"
|
2015-11-05 19:36:26 +01:00
|
|
|
ei_set_sitename()
|
|
|
|
|
|
|
|
# retrieve and store the build string
|
|
|
|
ei_set_build_string()
|
|
|
|
|
|
|
|
add_custom_target(buildtests)
|
|
|
|
add_custom_target(check COMMAND "ctest")
|
|
|
|
add_dependencies(check buildtests)
|
|
|
|
|
|
|
|
# check whether /bin/bash exists
|
|
|
|
find_file(EIGEN_BIN_BASH_EXISTS "/bin/bash" PATHS "/" NO_DEFAULT_PATH)
|
|
|
|
|
|
|
|
# This call activates testing and generates the DartConfiguration.tcl
|
|
|
|
include(CTest)
|
|
|
|
|
2016-10-04 08:03:44 +02:00
|
|
|
set(EIGEN_TEST_BUILD_FLAGS "" CACHE STRING "Options passed to the build command of unit tests")
|
2015-11-05 19:36:26 +01:00
|
|
|
|
2015-12-09 01:58:08 +01:00
|
|
|
# Overwrite default DartConfiguration.tcl such that ctest can build our unit tests.
|
|
|
|
# Recall that our unit tests are not in the "all" target, so we have to explicitely ask ctest to build our custom 'buildtests' target.
|
|
|
|
# At this stage, we can also add custom flags to the build tool through the user defined EIGEN_TEST_BUILD_FLAGS variable.
|
|
|
|
file(READ "${CMAKE_CURRENT_BINARY_DIR}/DartConfiguration.tcl" EIGEN_DART_CONFIG_FILE)
|
|
|
|
# try to grab the default flags
|
|
|
|
string(REGEX MATCH "MakeCommand:.*-- (.*)\nDefaultCTestConfigurationType" EIGEN_DUMMY ${EIGEN_DART_CONFIG_FILE})
|
|
|
|
if(NOT CMAKE_MATCH_1)
|
|
|
|
string(REGEX MATCH "MakeCommand:.*[^c]make (.*)\nDefaultCTestConfigurationType" EIGEN_DUMMY ${EIGEN_DART_CONFIG_FILE})
|
2015-11-05 19:36:26 +01:00
|
|
|
endif()
|
2015-12-09 01:58:08 +01:00
|
|
|
string(REGEX REPLACE "MakeCommand:.*DefaultCTestConfigurationType" "MakeCommand: ${CMAKE_COMMAND} --build . --target buildtests --config \"\${CTEST_CONFIGURATION_TYPE}\" -- ${CMAKE_MATCH_1} ${EIGEN_TEST_BUILD_FLAGS}\nDefaultCTestConfigurationType"
|
|
|
|
EIGEN_DART_CONFIG_FILE2 ${EIGEN_DART_CONFIG_FILE})
|
|
|
|
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/DartConfiguration.tcl" ${EIGEN_DART_CONFIG_FILE2})
|
2015-11-05 19:36:26 +01:00
|
|
|
|
|
|
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CTestCustom.cmake.in ${CMAKE_BINARY_DIR}/CTestCustom.cmake)
|
|
|
|
|
|
|
|
# some documentation of this function would be nice
|
|
|
|
ei_init_testing()
|
|
|
|
|
|
|
|
# configure Eigen related testing options
|
|
|
|
option(EIGEN_NO_ASSERTION_CHECKING "Disable checking of assertions using exceptions" OFF)
|
|
|
|
option(EIGEN_DEBUG_ASSERTS "Enable advanced debuging of assertions" OFF)
|
|
|
|
|
|
|
|
if(CMAKE_COMPILER_IS_GNUCXX)
|
|
|
|
option(EIGEN_COVERAGE_TESTING "Enable/disable gcov" OFF)
|
|
|
|
if(EIGEN_COVERAGE_TESTING)
|
|
|
|
set(COVERAGE_FLAGS "-fprofile-arcs -ftest-coverage")
|
|
|
|
set(CTEST_CUSTOM_COVERAGE_EXCLUDE "/test/")
|
2017-10-24 23:57:35 +02:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COVERAGE_FLAGS}")
|
2015-11-05 19:36:26 +01:00
|
|
|
endif(EIGEN_COVERAGE_TESTING)
|
2017-10-24 23:57:35 +02:00
|
|
|
|
2015-11-05 19:36:26 +01:00
|
|
|
elseif(MSVC)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D_CRT_SECURE_NO_WARNINGS /D_SCL_SECURE_NO_WARNINGS")
|
|
|
|
endif(CMAKE_COMPILER_IS_GNUCXX)
|
2017-10-24 23:57:35 +02:00
|
|
|
|
|
|
|
|
|
|
|
check_cxx_compiler_flag("-std=c++11" EIGEN_COMPILER_SUPPORT_CXX11)
|
|
|
|
|
|
|
|
if(EIGEN_TEST_CXX11 AND EIGEN_COMPILER_SUPPORT_CXX11)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
|
|
|
endif()
|