1*bf2c3715SXin Liinclude(EigenTesting) 2*bf2c3715SXin Liinclude(CheckCXXSourceCompiles) 3*bf2c3715SXin Li 4*bf2c3715SXin Li# configure the "site" and "buildname" 5*bf2c3715SXin Liei_set_sitename() 6*bf2c3715SXin Li 7*bf2c3715SXin Li# retrieve and store the build string 8*bf2c3715SXin Liei_set_build_string() 9*bf2c3715SXin Li 10*bf2c3715SXin Liadd_custom_target(buildtests) 11*bf2c3715SXin Liadd_custom_target(check COMMAND "ctest") 12*bf2c3715SXin Liadd_dependencies(check buildtests) 13*bf2c3715SXin Li 14*bf2c3715SXin Li# check whether /bin/bash exists (disabled as not used anymore) 15*bf2c3715SXin Li# find_file(EIGEN_BIN_BASH_EXISTS "/bin/bash" PATHS "/" NO_DEFAULT_PATH) 16*bf2c3715SXin Li 17*bf2c3715SXin Li# This call activates testing and generates the DartConfiguration.tcl 18*bf2c3715SXin Liinclude(CTest) 19*bf2c3715SXin Li 20*bf2c3715SXin Liset(EIGEN_TEST_BUILD_FLAGS "" CACHE STRING "Options passed to the build command of unit tests") 21*bf2c3715SXin Liset(EIGEN_DASHBOARD_BUILD_TARGET "buildtests" CACHE STRING "Target to be built in dashboard mode, default is buildtests") 22*bf2c3715SXin Liset(EIGEN_CTEST_ERROR_EXCEPTION "" CACHE STRING "Regular expression for build error messages to be filtered out") 23*bf2c3715SXin Li 24*bf2c3715SXin Li# Overwrite default DartConfiguration.tcl such that ctest can build our unit tests. 25*bf2c3715SXin Li# Recall that our unit tests are not in the "all" target, so we have to explicitly ask ctest to build our custom 'buildtests' target. 26*bf2c3715SXin Li# At this stage, we can also add custom flags to the build tool through the user defined EIGEN_TEST_BUILD_FLAGS variable. 27*bf2c3715SXin Lifile(READ "${CMAKE_CURRENT_BINARY_DIR}/DartConfiguration.tcl" EIGEN_DART_CONFIG_FILE) 28*bf2c3715SXin Li# try to grab the default flags 29*bf2c3715SXin Listring(REGEX MATCH "MakeCommand:.*-- (.*)\nDefaultCTestConfigurationType" EIGEN_DUMMY ${EIGEN_DART_CONFIG_FILE}) 30*bf2c3715SXin Liif(NOT CMAKE_MATCH_1) 31*bf2c3715SXin Listring(REGEX MATCH "MakeCommand:.*[^c]make (.*)\nDefaultCTestConfigurationType" EIGEN_DUMMY ${EIGEN_DART_CONFIG_FILE}) 32*bf2c3715SXin Liendif() 33*bf2c3715SXin Listring(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" 34*bf2c3715SXin Li EIGEN_DART_CONFIG_FILE2 ${EIGEN_DART_CONFIG_FILE}) 35*bf2c3715SXin Lifile(WRITE "${CMAKE_CURRENT_BINARY_DIR}/DartConfiguration.tcl" ${EIGEN_DART_CONFIG_FILE2}) 36*bf2c3715SXin Li 37*bf2c3715SXin Liconfigure_file(${CMAKE_CURRENT_SOURCE_DIR}/CTestCustom.cmake.in ${CMAKE_BINARY_DIR}/CTestCustom.cmake) 38*bf2c3715SXin Li 39*bf2c3715SXin Li# some documentation of this function would be nice 40*bf2c3715SXin Liei_init_testing() 41*bf2c3715SXin Li 42*bf2c3715SXin Li# configure Eigen related testing options 43*bf2c3715SXin Lioption(EIGEN_NO_ASSERTION_CHECKING "Disable checking of assertions using exceptions" OFF) 44*bf2c3715SXin Lioption(EIGEN_DEBUG_ASSERTS "Enable advanced debugging of assertions" OFF) 45*bf2c3715SXin Li 46*bf2c3715SXin Liif(CMAKE_COMPILER_IS_GNUCXX) 47*bf2c3715SXin Li option(EIGEN_COVERAGE_TESTING "Enable/disable gcov" OFF) 48*bf2c3715SXin Li if(EIGEN_COVERAGE_TESTING) 49*bf2c3715SXin Li set(COVERAGE_FLAGS "-fprofile-arcs -ftest-coverage") 50*bf2c3715SXin Li set(CTEST_CUSTOM_COVERAGE_EXCLUDE "/test/") 51*bf2c3715SXin Li set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COVERAGE_FLAGS}") 52*bf2c3715SXin Li endif() 53*bf2c3715SXin Li 54*bf2c3715SXin Lielseif(MSVC) 55*bf2c3715SXin Li set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D_CRT_SECURE_NO_WARNINGS /D_SCL_SECURE_NO_WARNINGS") 56*bf2c3715SXin Liendif() 57*bf2c3715SXin Li 58*bf2c3715SXin Li 59