2009-11-12 05:11:33 +08:00
|
|
|
option(EIGEN_NO_ASSERTION_CHECKING "Disable checking of assertions using exceptions" OFF)
|
|
|
|
option(EIGEN_DEBUG_ASSERTS "Enable advanced debuging of assertions" OFF)
|
2009-02-05 01:11:04 +08:00
|
|
|
|
2009-02-28 00:19:13 +08:00
|
|
|
macro(ei_add_property prop value)
|
|
|
|
get_property(previous GLOBAL PROPERTY ${prop})
|
2009-05-15 23:53:26 +08:00
|
|
|
set_property(GLOBAL PROPERTY ${prop} "${previous} ${value}")
|
2009-02-28 00:19:13 +08:00
|
|
|
endmacro(ei_add_property)
|
|
|
|
|
2009-10-20 01:29:00 +08:00
|
|
|
#internal. See documentation of ei_add_test for details.
|
|
|
|
macro(ei_add_test_internal testname testname_with_suffix)
|
2009-12-03 01:07:47 +08:00
|
|
|
set(targetname ${testname_with_suffix})
|
2009-02-05 01:11:04 +08:00
|
|
|
|
|
|
|
set(filename ${testname}.cpp)
|
|
|
|
add_executable(${targetname} ${filename})
|
2009-11-13 04:02:52 +08:00
|
|
|
add_dependencies(buildtests ${targetname})
|
2009-02-05 01:11:04 +08:00
|
|
|
|
2009-11-12 05:11:33 +08:00
|
|
|
if(EIGEN_NO_ASSERTION_CHECKING)
|
|
|
|
ei_add_target_property(${targetname} COMPILE_FLAGS "-DEIGEN_NO_ASSERTION_CHECKING=1")
|
|
|
|
else(EIGEN_NO_ASSERTION_CHECKING)
|
2009-02-05 01:11:04 +08:00
|
|
|
if(EIGEN_DEBUG_ASSERTS)
|
2009-05-15 23:53:26 +08:00
|
|
|
ei_add_target_property(${targetname} COMPILE_FLAGS "-DEIGEN_DEBUG_ASSERTS=1")
|
2009-02-05 01:11:04 +08:00
|
|
|
endif(EIGEN_DEBUG_ASSERTS)
|
2009-11-12 05:11:33 +08:00
|
|
|
endif(EIGEN_NO_ASSERTION_CHECKING)
|
2009-02-05 01:11:04 +08:00
|
|
|
|
2009-11-12 05:11:33 +08:00
|
|
|
ei_add_target_property(${targetname} COMPILE_FLAGS "-DEIGEN_TEST_FUNC=${testname}")
|
2009-02-05 01:11:04 +08:00
|
|
|
|
2009-11-12 05:11:33 +08:00
|
|
|
# let the user pass flags.
|
2009-10-20 01:29:00 +08:00
|
|
|
if(${ARGC} GREATER 2)
|
|
|
|
ei_add_target_property(${targetname} COMPILE_FLAGS "${ARGV2}")
|
|
|
|
endif(${ARGC} GREATER 2)
|
2009-02-05 01:11:04 +08:00
|
|
|
|
2010-04-19 23:19:22 +08:00
|
|
|
if(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO)
|
|
|
|
target_link_libraries(${targetname} ${EIGEN_STANDARD_LIBRARIES_TO_LINK_TO})
|
|
|
|
endif()
|
2009-11-12 05:11:33 +08:00
|
|
|
if(EXTERNAL_LIBS)
|
|
|
|
target_link_libraries(${targetname} ${EXTERNAL_LIBS})
|
|
|
|
endif()
|
2010-10-17 23:04:43 +08:00
|
|
|
|
2009-10-20 01:29:00 +08:00
|
|
|
if(${ARGC} GREATER 3)
|
2010-10-28 22:44:20 +08:00
|
|
|
set(libs_to_link ${ARGV3})
|
|
|
|
# it could be that some cmake module provides a bad library string " " (just spaces),
|
|
|
|
# and that severely breaks target_link_libraries ("can't link to -l-lstdc++" errors).
|
|
|
|
# so we check for strings containing only spaces.
|
|
|
|
string(STRIP "${libs_to_link}" libs_to_link_stripped)
|
|
|
|
string(LENGTH "${libs_to_link_stripped}" libs_to_link_stripped_length)
|
|
|
|
if(${libs_to_link_stripped_length} GREATER 0)
|
|
|
|
# notice: no double quotes around ${libs_to_link} here. It may be a list.
|
|
|
|
target_link_libraries(${targetname} ${libs_to_link})
|
|
|
|
endif()
|
2010-10-17 23:04:43 +08:00
|
|
|
endif()
|
2009-02-05 01:11:04 +08:00
|
|
|
|
|
|
|
if(WIN32)
|
2009-10-05 20:00:32 +08:00
|
|
|
if(CYGWIN)
|
2009-10-20 01:29:00 +08:00
|
|
|
add_test(${testname_with_suffix} "${Eigen_SOURCE_DIR}/test/runtest.sh" "${testname_with_suffix}")
|
2009-10-05 20:00:32 +08:00
|
|
|
else(CYGWIN)
|
2009-10-20 01:29:00 +08:00
|
|
|
add_test(${testname_with_suffix} "${targetname}")
|
2009-10-05 20:00:32 +08:00
|
|
|
endif(CYGWIN)
|
2009-02-05 01:11:04 +08:00
|
|
|
else(WIN32)
|
2009-10-20 01:29:00 +08:00
|
|
|
add_test(${testname_with_suffix} "${Eigen_SOURCE_DIR}/test/runtest.sh" "${testname_with_suffix}")
|
2009-02-05 01:11:04 +08:00
|
|
|
endif(WIN32)
|
|
|
|
|
2009-10-20 01:29:00 +08:00
|
|
|
endmacro(ei_add_test_internal)
|
|
|
|
|
|
|
|
|
|
|
|
# Macro to add a test
|
|
|
|
#
|
2009-10-20 03:56:03 +08:00
|
|
|
# the unique mandatory parameter testname must correspond to a file
|
2009-10-20 01:29:00 +08:00
|
|
|
# <testname>.cpp which follows this pattern:
|
|
|
|
#
|
|
|
|
# #include "main.h"
|
|
|
|
# void test_<testname>() { ... }
|
|
|
|
#
|
2009-10-20 03:56:03 +08:00
|
|
|
# Depending on the contents of that file, this macro can have 2 behaviors,
|
|
|
|
# see below.
|
|
|
|
#
|
2009-11-12 05:11:33 +08:00
|
|
|
# The optional 2nd parameter is libraries to link to.
|
2009-10-20 02:40:35 +08:00
|
|
|
#
|
|
|
|
# A. Default behavior
|
|
|
|
#
|
2009-12-03 01:07:47 +08:00
|
|
|
# this macro adds an executable <testname> as well as a ctest test
|
|
|
|
# named <testname> too.
|
2009-10-20 01:29:00 +08:00
|
|
|
#
|
|
|
|
# On platforms with bash simply run:
|
|
|
|
# "ctest -V" or "ctest -V -R <testname>"
|
|
|
|
# On other platform use ctest as usual
|
|
|
|
#
|
2009-10-20 02:40:35 +08:00
|
|
|
# B. Multi-part behavior
|
2009-10-20 01:29:00 +08:00
|
|
|
#
|
2009-10-20 02:40:35 +08:00
|
|
|
# If the source file matches the regexp
|
2009-11-12 05:11:33 +08:00
|
|
|
# CALL_SUBTEST_[0-9]+|EIGEN_TEST_PART_[0-9]+
|
2009-10-20 02:40:35 +08:00
|
|
|
# then it is interpreted as a multi-part test. The behavior then depends on the
|
|
|
|
# CMake option EIGEN_SPLIT_LARGE_TESTS, which is ON by default.
|
2009-10-20 01:29:00 +08:00
|
|
|
#
|
2009-10-20 02:40:35 +08:00
|
|
|
# If EIGEN_SPLIT_LARGE_TESTS is OFF, the behavior is the same as in A (the multi-part
|
|
|
|
# aspect is ignored).
|
2009-10-20 01:29:00 +08:00
|
|
|
#
|
2009-10-20 02:40:35 +08:00
|
|
|
# If EIGEN_SPLIT_LARGE_TESTS is ON, the test is split into multiple executables
|
|
|
|
# test_<testname>_<N>
|
|
|
|
# where N runs from 1 to the greatest occurence found in the source file. Each of these
|
|
|
|
# executables is built passing -DEIGEN_TEST_PART_N. This allows to split large tests
|
|
|
|
# into smaller executables.
|
2009-10-20 01:29:00 +08:00
|
|
|
#
|
2009-12-03 01:07:47 +08:00
|
|
|
# Moreover, targets <testname> are still generated, they
|
2009-10-20 02:40:35 +08:00
|
|
|
# have the effect of building all the parts of the test.
|
2009-10-20 01:29:00 +08:00
|
|
|
#
|
2009-10-20 02:40:35 +08:00
|
|
|
# Again, ctest -R allows to run all matching tests.
|
|
|
|
macro(ei_add_test testname)
|
2009-11-26 10:26:37 +08:00
|
|
|
get_property(EIGEN_TESTS_LIST GLOBAL PROPERTY EIGEN_TESTS_LIST)
|
|
|
|
set(EIGEN_TESTS_LIST "${EIGEN_TESTS_LIST}${testname}\n")
|
|
|
|
set_property(GLOBAL PROPERTY EIGEN_TESTS_LIST "${EIGEN_TESTS_LIST}")
|
|
|
|
|
2009-10-20 02:40:35 +08:00
|
|
|
file(READ "${testname}.cpp" test_source)
|
|
|
|
set(parts 0)
|
2009-10-29 06:19:29 +08:00
|
|
|
string(REGEX MATCHALL "CALL_SUBTEST_[0-9]+|EIGEN_TEST_PART_[0-9]+"
|
|
|
|
occurences "${test_source}")
|
|
|
|
string(REGEX REPLACE "CALL_SUBTEST_|EIGEN_TEST_PART_" "" suffixes "${occurences}")
|
|
|
|
list(REMOVE_DUPLICATES suffixes)
|
|
|
|
if(EIGEN_SPLIT_LARGE_TESTS AND suffixes)
|
2009-12-03 01:07:47 +08:00
|
|
|
add_custom_target(${testname})
|
2009-10-29 06:19:29 +08:00
|
|
|
foreach(suffix ${suffixes})
|
|
|
|
ei_add_test_internal(${testname} ${testname}_${suffix}
|
|
|
|
"${ARGV1} -DEIGEN_TEST_PART_${suffix}=1" "${ARGV2}")
|
2009-12-03 01:07:47 +08:00
|
|
|
add_dependencies(${testname} ${testname}_${suffix})
|
2009-10-29 06:19:29 +08:00
|
|
|
endforeach(suffix)
|
|
|
|
else(EIGEN_SPLIT_LARGE_TESTS AND suffixes)
|
2009-10-20 01:29:00 +08:00
|
|
|
set(symbols_to_enable_all_parts "")
|
2009-10-29 06:19:29 +08:00
|
|
|
foreach(suffix ${suffixes})
|
|
|
|
set(symbols_to_enable_all_parts
|
|
|
|
"${symbols_to_enable_all_parts} -DEIGEN_TEST_PART_${suffix}=1")
|
|
|
|
endforeach(suffix)
|
2009-10-20 02:40:35 +08:00
|
|
|
ei_add_test_internal(${testname} ${testname} "${ARGV1} ${symbols_to_enable_all_parts}" "${ARGV2}")
|
2009-10-29 06:19:29 +08:00
|
|
|
endif(EIGEN_SPLIT_LARGE_TESTS AND suffixes)
|
2009-10-20 02:40:35 +08:00
|
|
|
endmacro(ei_add_test)
|
2009-10-20 01:29:00 +08:00
|
|
|
|
2009-02-28 00:19:13 +08:00
|
|
|
# print a summary of the different options
|
|
|
|
macro(ei_testing_print_summary)
|
|
|
|
|
2010-12-30 05:02:01 +08:00
|
|
|
message(STATUS "************************************************************")
|
|
|
|
message(STATUS "*** Eigen's unit tests configuration summary ***")
|
|
|
|
message(STATUS "************************************************************")
|
|
|
|
message(STATUS "")
|
|
|
|
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
|
2009-02-28 00:19:13 +08:00
|
|
|
get_property(EIGEN_TESTING_SUMMARY GLOBAL PROPERTY EIGEN_TESTING_SUMMARY)
|
|
|
|
get_property(EIGEN_TESTED_BACKENDS GLOBAL PROPERTY EIGEN_TESTED_BACKENDS)
|
|
|
|
get_property(EIGEN_MISSING_BACKENDS GLOBAL PROPERTY EIGEN_MISSING_BACKENDS)
|
2010-12-30 05:02:01 +08:00
|
|
|
message(STATUS "Enabled backends: ${EIGEN_TESTED_BACKENDS}")
|
|
|
|
message(STATUS "Disabled backends: ${EIGEN_MISSING_BACKENDS}")
|
2009-02-28 00:19:13 +08:00
|
|
|
|
2010-01-27 20:48:48 +08:00
|
|
|
if(EIGEN_DEFAULT_TO_ROW_MAJOR)
|
2010-12-30 05:02:01 +08:00
|
|
|
message(STATUS "Default order: Row-major")
|
2010-01-27 20:48:48 +08:00
|
|
|
else()
|
2010-12-30 05:02:01 +08:00
|
|
|
message(STATUS "Default order: Column-major")
|
2010-01-27 20:48:48 +08:00
|
|
|
endif()
|
|
|
|
|
2010-03-06 15:17:37 +08:00
|
|
|
if(EIGEN_TEST_NO_EXPLICIT_ALIGNMENT)
|
2010-12-30 05:02:01 +08:00
|
|
|
message(STATUS "Explicit alignment (hence vectorization) disabled")
|
2010-03-06 15:17:37 +08:00
|
|
|
elseif(EIGEN_TEST_NO_EXPLICIT_VECTORIZATION)
|
2010-12-30 05:02:01 +08:00
|
|
|
message(STATUS "Explicit vectorization disabled (alignment kept enabled)")
|
2009-11-25 04:12:43 +08:00
|
|
|
else()
|
2009-02-28 00:19:13 +08:00
|
|
|
|
2010-03-06 15:17:37 +08:00
|
|
|
if(EIGEN_TEST_SSE2)
|
2010-12-30 05:02:01 +08:00
|
|
|
message(STATUS "SSE2: ON")
|
2010-03-06 15:17:37 +08:00
|
|
|
else()
|
2010-12-30 05:02:01 +08:00
|
|
|
message(STATUS "SSE2: Using architecture defaults")
|
2010-03-06 15:17:37 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(EIGEN_TEST_SSE3)
|
2010-12-30 05:02:01 +08:00
|
|
|
message(STATUS "SSE3: ON")
|
2010-03-06 15:17:37 +08:00
|
|
|
else()
|
2010-12-30 05:02:01 +08:00
|
|
|
message(STATUS "SSE3: Using architecture defaults")
|
2010-03-06 15:17:37 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(EIGEN_TEST_SSSE3)
|
2010-12-30 05:02:01 +08:00
|
|
|
message(STATUS "SSSE3: ON")
|
2010-03-06 15:17:37 +08:00
|
|
|
else()
|
2010-12-30 05:02:01 +08:00
|
|
|
message(STATUS "SSSE3: Using architecture defaults")
|
2010-03-06 15:17:37 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(EIGEN_TEST_SSE4_1)
|
2010-12-30 05:02:01 +08:00
|
|
|
message(STATUS "SSE4.1: ON")
|
2010-03-06 15:17:37 +08:00
|
|
|
else()
|
2010-12-30 05:02:01 +08:00
|
|
|
message(STATUS "SSE4.1: Using architecture defaults")
|
2010-03-06 15:17:37 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(EIGEN_TEST_SSE4_2)
|
2010-12-30 05:02:01 +08:00
|
|
|
message(STATUS "SSE4.2: ON")
|
2010-03-06 15:17:37 +08:00
|
|
|
else()
|
2010-12-30 05:02:01 +08:00
|
|
|
message(STATUS "SSE4.2: Using architecture defaults")
|
2010-03-06 15:17:37 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(EIGEN_TEST_ALTIVEC)
|
2010-12-30 05:02:01 +08:00
|
|
|
message(STATUS "Altivec: ON")
|
2010-03-06 15:17:37 +08:00
|
|
|
else()
|
2010-12-30 05:02:01 +08:00
|
|
|
message(STATUS "Altivec: Using architecture defaults")
|
2010-03-06 15:17:37 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(EIGEN_TEST_NEON)
|
2010-12-30 05:02:01 +08:00
|
|
|
message(STATUS "ARM NEON: ON")
|
2010-03-06 15:17:37 +08:00
|
|
|
else()
|
2010-12-30 05:02:01 +08:00
|
|
|
message(STATUS "ARM NEON: Using architecture defaults")
|
2010-03-06 15:17:37 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
endif() # vectorization / alignment options
|
2009-02-28 00:19:13 +08:00
|
|
|
|
2010-12-30 05:02:01 +08:00
|
|
|
message(STATUS "\n${EIGEN_TESTING_SUMMARY}")
|
2009-02-28 00:19:13 +08:00
|
|
|
|
2010-12-30 05:02:01 +08:00
|
|
|
message(STATUS "************************************************************")
|
2009-02-28 00:19:13 +08:00
|
|
|
|
|
|
|
endmacro(ei_testing_print_summary)
|
|
|
|
|
|
|
|
macro(ei_init_testing)
|
|
|
|
define_property(GLOBAL PROPERTY EIGEN_TESTED_BACKENDS BRIEF_DOCS " " FULL_DOCS " ")
|
|
|
|
define_property(GLOBAL PROPERTY EIGEN_MISSING_BACKENDS BRIEF_DOCS " " FULL_DOCS " ")
|
|
|
|
define_property(GLOBAL PROPERTY EIGEN_TESTING_SUMMARY BRIEF_DOCS " " FULL_DOCS " ")
|
2009-11-26 10:26:37 +08:00
|
|
|
define_property(GLOBAL PROPERTY EIGEN_TESTS_LIST BRIEF_DOCS " " FULL_DOCS " ")
|
2009-02-28 00:19:13 +08:00
|
|
|
|
|
|
|
set_property(GLOBAL PROPERTY EIGEN_TESTED_BACKENDS "")
|
|
|
|
set_property(GLOBAL PROPERTY EIGEN_MISSING_BACKENDS "")
|
|
|
|
set_property(GLOBAL PROPERTY EIGEN_TESTING_SUMMARY "")
|
2009-11-26 10:26:37 +08:00
|
|
|
set_property(GLOBAL PROPERTY EIGEN_TESTS_LIST "")
|
2009-02-28 00:19:13 +08:00
|
|
|
endmacro(ei_init_testing)
|
|
|
|
|
|
|
|
if(CMAKE_COMPILER_IS_GNUCXX)
|
2009-09-07 20:05:27 +08:00
|
|
|
option(EIGEN_COVERAGE_TESTING "Enable/disable gcov" OFF)
|
|
|
|
if(EIGEN_COVERAGE_TESTING)
|
|
|
|
set(COVERAGE_FLAGS "-fprofile-arcs -ftest-coverage")
|
2010-01-27 00:02:19 +08:00
|
|
|
set(CTEST_CUSTOM_COVERAGE_EXCLUDE "/test/")
|
2009-09-07 20:05:27 +08:00
|
|
|
else(EIGEN_COVERAGE_TESTING)
|
|
|
|
set(COVERAGE_FLAGS "")
|
2009-09-08 16:20:26 +08:00
|
|
|
endif(EIGEN_COVERAGE_TESTING)
|
2009-12-12 18:39:07 +08:00
|
|
|
if(EIGEN_TEST_C++0x)
|
2009-11-30 23:54:04 +08:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x")
|
2009-12-12 18:39:07 +08:00
|
|
|
endif(EIGEN_TEST_C++0x)
|
2009-02-28 00:19:13 +08:00
|
|
|
if(CMAKE_SYSTEM_NAME MATCHES Linux)
|
2009-09-07 20:05:27 +08:00
|
|
|
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")
|
2009-10-20 01:29:00 +08:00
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${COVERAGE_FLAGS} -O0 -g3")
|
2009-02-28 00:19:13 +08:00
|
|
|
endif(CMAKE_SYSTEM_NAME MATCHES Linux)
|
2009-08-29 02:14:18 +08:00
|
|
|
elseif(MSVC)
|
2009-12-12 18:39:07 +08:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D_CRT_SECURE_NO_WARNINGS /D_SCL_SECURE_NO_WARNINGS")
|
2009-02-28 00:19:13 +08:00
|
|
|
endif(CMAKE_COMPILER_IS_GNUCXX)
|