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)
|
|
|
|
|
2011-11-10 04:19:05 +08:00
|
|
|
# check whether /bin/bash exists
|
|
|
|
find_file(EIGEN_BIN_BASH_EXISTS "/bin/bash" PATHS "/" NO_DEFAULT_PATH)
|
|
|
|
|
2011-02-20 18:54:07 +08:00
|
|
|
# CMake/Ctest does not allow us to change the build command,
|
|
|
|
# so we have to workaround by directly editing the generated DartConfiguration.tcl file
|
|
|
|
# save CMAKE_MAKE_PROGRAM
|
|
|
|
set(CMAKE_MAKE_PROGRAM_SAVE ${CMAKE_MAKE_PROGRAM})
|
|
|
|
# and set a fake one
|
|
|
|
set(CMAKE_MAKE_PROGRAM "@EIGEN_MAKECOMMAND_PLACEHOLDER@")
|
|
|
|
|
|
|
|
# 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")
|
2013-07-07 23:25:58 +08:00
|
|
|
|
2011-02-20 18:54:07 +08:00
|
|
|
# overwrite default DartConfiguration.tcl
|
|
|
|
# The worarounds are different for each version of the MSVC IDE
|
2013-07-31 22:16:08 +08:00
|
|
|
set(EIGEN_TEST_TARGET buildtests)
|
2011-02-20 18:54:07 +08:00
|
|
|
if(MSVC_IDE)
|
2013-02-27 22:54:27 +08:00
|
|
|
if(CMAKE_MAKE_PROGRAM_SAVE MATCHES "devenv") # devenv
|
2013-07-31 22:16:08 +08:00
|
|
|
set(EIGEN_BUILD_COMMAND "${CMAKE_MAKE_PROGRAM_SAVE} Eigen.sln /build Release /project ${EIGEN_TEST_TARGET}")
|
2013-02-27 22:54:27 +08:00
|
|
|
else() # msbuild
|
2013-07-31 22:16:08 +08:00
|
|
|
set(EIGEN_BUILD_COMMAND "${CMAKE_MAKE_PROGRAM_SAVE} ${EIGEN_TEST_TARGET}.vcxproj /p:Configuration=\${CTEST_CONFIGURATION_TYPE}")
|
2011-02-20 18:54:07 +08:00
|
|
|
endif()
|
2013-07-31 22:16:08 +08:00
|
|
|
|
|
|
|
# append the build flags if provided
|
|
|
|
if(NOT "${EIGEN_TEST_BUILD_FLAGS}" MATCHES "^[ \t]*$")
|
|
|
|
set(EIGEN_BUILD_COMMAND "${EIGEN_BUILD_COMMAND} ${EIGEN_TEST_BUILD_FLAGS}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# apply the dartconfig hack ...
|
|
|
|
set(EIGEN_MAKECOMMAND_PLACEHOLDER "${EIGEN_BUILD_COMMAND}\n#")
|
2011-02-20 18:54:07 +08:00
|
|
|
else()
|
|
|
|
# for make and nmake
|
2013-07-31 22:16:08 +08:00
|
|
|
set(EIGEN_BUILD_COMMAND "${CMAKE_MAKE_PROGRAM_SAVE} ${EIGEN_TEST_TARGET} ${EIGEN_TEST_BUILD_FLAGS}")
|
|
|
|
set(EIGEN_MAKECOMMAND_PLACEHOLDER "${EIGEN_BUILD_COMMAND}")
|
2011-02-20 18:54:07 +08:00
|
|
|
endif()
|
|
|
|
|
2014-06-06 17:06:44 +08:00
|
|
|
configure_file(${CMAKE_CURRENT_BINARY_DIR}/DartConfiguration.tcl ${CMAKE_BINARY_DIR}/DartConfiguration.tcl)
|
2011-02-20 18:54:07 +08:00
|
|
|
|
|
|
|
# restore default CMAKE_MAKE_PROGRAM
|
|
|
|
set(CMAKE_MAKE_PROGRAM ${CMAKE_MAKE_PROGRAM_SAVE})
|
2013-07-31 22:16:08 +08:00
|
|
|
|
|
|
|
# un-set temporary variables so that it is like they never existed
|
|
|
|
unset(CMAKE_MAKE_PROGRAM_SAVE)
|
|
|
|
unset(EIGEN_MAKECOMMAND_PLACEHOLDER)
|
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)
|
|
|
|
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/")
|
|
|
|
else(EIGEN_COVERAGE_TESTING)
|
|
|
|
set(COVERAGE_FLAGS "")
|
|
|
|
endif(EIGEN_COVERAGE_TESTING)
|
|
|
|
if(EIGEN_TEST_C++0x)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x")
|
|
|
|
endif(EIGEN_TEST_C++0x)
|
|
|
|
if(CMAKE_SYSTEM_NAME MATCHES Linux)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COVERAGE_FLAGS} -g2")
|
|
|
|
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${COVERAGE_FLAGS} -O2 -g2")
|
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${COVERAGE_FLAGS} -fno-inline-functions")
|
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${COVERAGE_FLAGS} -O0 -g3")
|
|
|
|
endif(CMAKE_SYSTEM_NAME MATCHES Linux)
|
|
|
|
elseif(MSVC)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D_CRT_SECURE_NO_WARNINGS /D_SCL_SECURE_NO_WARNINGS")
|
|
|
|
endif(CMAKE_COMPILER_IS_GNUCXX)
|