2011-02-20 18:54:07 +08:00
|
|
|
include(EigenTesting)
|
|
|
|
include(CheckCXXSourceCompiles)
|
|
|
|
|
|
|
|
# configure the "site" and "buildname"
|
|
|
|
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)
|
|
|
|
|
2018-07-16 23:59:30 +08:00
|
|
|
# check whether /bin/bash exists (disabled as not used anymore)
|
|
|
|
# find_file(EIGEN_BIN_BASH_EXISTS "/bin/bash" PATHS "/" NO_DEFAULT_PATH)
|
2011-11-10 04:19:05 +08:00
|
|
|
|
2011-02-20 18:54:07 +08:00
|
|
|
# This call activates testing and generates the DartConfiguration.tcl
|
|
|
|
include(CTest)
|
|
|
|
|
2013-07-31 22:16:08 +08:00
|
|
|
set(EIGEN_TEST_BUILD_FLAGS "" CACHE STRING "Options passed to the build command of unit tests")
|
2018-07-16 23:59:30 +08:00
|
|
|
set(EIGEN_DASHBOARD_BUILD_TARGET "buildtests" CACHE STRING "Target to be built in dashboard mode, default is buildtests")
|
2018-07-25 02:12:49 +08:00
|
|
|
set(EIGEN_CTEST_ERROR_EXCEPTION "" CACHE STRING "Regular expression for build error messages to be filtered out")
|
2013-07-07 23:25:58 +08:00
|
|
|
|
2014-09-23 04:49:20 +08:00
|
|
|
# Overwrite default DartConfiguration.tcl such that ctest can build our unit tests.
|
2018-03-11 22:01:44 +08:00
|
|
|
# Recall that our unit tests are not in the "all" target, so we have to explicitly ask ctest to build our custom 'buildtests' target.
|
2014-09-23 04:49:20 +08:00
|
|
|
# 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)
|
2014-09-24 04:10:32 +08:00
|
|
|
# try to grab the default flags
|
2014-09-30 01:20:01 +08:00
|
|
|
string(REGEX MATCH "MakeCommand:.*-- (.*)\nDefaultCTestConfigurationType" EIGEN_DUMMY ${EIGEN_DART_CONFIG_FILE})
|
2014-09-24 04:10:32 +08:00
|
|
|
if(NOT CMAKE_MATCH_1)
|
2014-09-30 03:28:10 +08:00
|
|
|
string(REGEX MATCH "MakeCommand:.*[^c]make (.*)\nDefaultCTestConfigurationType" EIGEN_DUMMY ${EIGEN_DART_CONFIG_FILE})
|
2014-09-24 04:10:32 +08:00
|
|
|
endif()
|
2018-07-16 23:59:30 +08:00
|
|
|
string(REGEX REPLACE "MakeCommand:.*DefaultCTestConfigurationType" "MakeCommand: ${CMAKE_COMMAND} --build . --target ${EIGEN_DASHBOARD_BUILD_TARGET} --config \"\${CTEST_CONFIGURATION_TYPE}\" -- ${CMAKE_MATCH_1} ${EIGEN_TEST_BUILD_FLAGS}\nDefaultCTestConfigurationType"
|
2014-09-23 04:49:20 +08:00
|
|
|
EIGEN_DART_CONFIG_FILE2 ${EIGEN_DART_CONFIG_FILE})
|
|
|
|
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/DartConfiguration.tcl" ${EIGEN_DART_CONFIG_FILE2})
|
2011-02-20 18:54:07 +08:00
|
|
|
|
2014-06-06 17:06:44 +08:00
|
|
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CTestCustom.cmake.in ${CMAKE_BINARY_DIR}/CTestCustom.cmake)
|
2011-02-20 18:54:07 +08:00
|
|
|
|
|
|
|
# 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)
|
2018-03-11 22:01:44 +08:00
|
|
|
option(EIGEN_DEBUG_ASSERTS "Enable advanced debugging of assertions" OFF)
|
2011-02-20 18:54:07 +08:00
|
|
|
|
|
|
|
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/")
|
2015-12-01 00:05:42 +08:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COVERAGE_FLAGS}")
|
2019-11-01 00:36:27 +08:00
|
|
|
endif()
|
2015-02-20 16:31:27 +08:00
|
|
|
|
2011-02-20 18:54:07 +08:00
|
|
|
elseif(MSVC)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D_CRT_SECURE_NO_WARNINGS /D_SCL_SECURE_NO_WARNINGS")
|
2019-11-01 00:36:27 +08:00
|
|
|
endif()
|
2015-02-20 16:31:27 +08:00
|
|
|
|
|
|
|
|