diff options
author | Benoit Jacob <jacob.benoit.1@gmail.com> | 2009-10-19 13:29:00 -0400 |
---|---|---|
committer | Benoit Jacob <jacob.benoit.1@gmail.com> | 2009-10-19 13:29:00 -0400 |
commit | 580672ea43a29c7f0d10b6d92ffc07518500d4da (patch) | |
tree | 21b890ddc9ecaca4d71c545774024b038e4ccd74 /cmake/EigenTesting.cmake | |
parent | 9a700c297490024bd94edfcd73f14c8a984705c9 (diff) |
Add new default option EIGEN_SPLIT_LARGE_TESTS and cmake macro ei_add_test_multi.
When enabled, large tests are split into smaller executables.
This needs minimal changes in the unit tests.
Updated the LU test to use it.
Diffstat (limited to 'cmake/EigenTesting.cmake')
-rw-r--r-- | cmake/EigenTesting.cmake | 131 |
1 files changed, 92 insertions, 39 deletions
diff --git a/cmake/EigenTesting.cmake b/cmake/EigenTesting.cmake index b8e159be7..996b8443f 100644 --- a/cmake/EigenTesting.cmake +++ b/cmake/EigenTesting.cmake @@ -18,30 +18,11 @@ macro(ei_add_property prop value) set_property(GLOBAL PROPERTY ${prop} "${previous} ${value}") endmacro(ei_add_property) -# Macro to add a test -# -# the unique parameter testname must correspond to a file -# <testname>.cpp which follows this pattern: -# -# #include "main.h" -# void test_<testname>() { ... } -# -# this macro add an executable test_<testname> as well as a ctest test -# named <testname>. -# -# it also adds another executable debug_<testname> that compiles in full debug mode -# and is not added to the test target. The idea is that when a test fails you want -# a quick way of rebuilding this specific test in full debug mode. -# -# On platforms with bash simply run: -# "ctest -V" or "ctest -V -R <testname>" -# On other platform use ctest as usual -# -macro(ei_add_test testname) - - set(targetname test_${testname}) +#internal. See documentation of ei_add_test for details. +macro(ei_add_test_internal testname testname_with_suffix) + set(targetname test_${testname_with_suffix}) if(NOT MSVC_IDE) - set(debug_targetname debug_${testname}) + set(debug_targetname debug_${testname_with_suffix}) endif(NOT MSVC_IDE) set(filename ${testname}.cpp) @@ -80,10 +61,14 @@ macro(ei_add_test testname) endif(NOT EIGEN_NO_ASSERTION_CHECKING) - # let the user pass e.g. optimization flags, but don't apply them to the debug target - if(${ARGC} GREATER 1) - ei_add_target_property(${targetname} COMPILE_FLAGS "${ARGV1}") - endif(${ARGC} GREATER 1) + # let the user pass flags. Note that if the user passes an optimization flag here, it's important that + # we counter it by a no-optimization flag! + if(${ARGC} GREATER 2) + ei_add_target_property(${targetname} COMPILE_FLAGS "${ARGV2}") + if(NOT MSVC_IDE) + ei_add_target_property(${debug_targetname} COMPILE_FLAGS "${ARGV2} ${EI_NO_OPTIMIZATION_FLAG}") + endif(NOT MSVC_IDE) + endif(${ARGC} GREATER 2) # for the debug target, add full debug options if(CMAKE_COMPILER_IS_GNUCXX) @@ -101,29 +86,94 @@ macro(ei_add_test testname) endif(NOT MSVC_IDE) target_link_libraries(${targetname} ${EXTERNAL_LIBS}) - if(${ARGC} GREATER 2) - string(STRIP "${ARGV2}" ARGV2_stripped) - string(LENGTH "${ARGV2_stripped}" ARGV2_stripped_length) - if(${ARGV2_stripped_length} GREATER 0) - target_link_libraries(${targetname} ${ARGV2}) + if(${ARGC} GREATER 3) + string(STRIP "${ARGV3}" ARGV3_stripped) + string(LENGTH "${ARGV3_stripped}" ARGV3_stripped_length) + if(${ARGV3_stripped_length} GREATER 0) + target_link_libraries(${targetname} ${ARGV3}) if(NOT MSVC_IDE) - target_link_libraries(${debug_targetname} ${ARGV2}) + target_link_libraries(${debug_targetname} ${ARGV3}) endif(NOT MSVC_IDE) - endif(${ARGV2_stripped_length} GREATER 0) - endif(${ARGC} GREATER 2) + endif(${ARGV3_stripped_length} GREATER 0) + endif(${ARGC} GREATER 3) if(WIN32) if(CYGWIN) - add_test(${testname} "${Eigen_SOURCE_DIR}/test/runtest.sh" "${testname}") + add_test(${testname_with_suffix} "${Eigen_SOURCE_DIR}/test/runtest.sh" "${testname_with_suffix}") else(CYGWIN) - add_test(${testname} "${targetname}") + add_test(${testname_with_suffix} "${targetname}") endif(CYGWIN) else(WIN32) - add_test(${testname} "${Eigen_SOURCE_DIR}/test/runtest.sh" "${testname}") + add_test(${testname_with_suffix} "${Eigen_SOURCE_DIR}/test/runtest.sh" "${testname_with_suffix}") endif(WIN32) +endmacro(ei_add_test_internal) + + +# Macro to add a test +# +# the unique parameter testname must correspond to a file +# <testname>.cpp which follows this pattern: +# +# #include "main.h" +# void test_<testname>() { ... } +# +# this macro add an executable test_<testname> as well as a ctest test +# named <testname>. +# +# it also adds another executable debug_<testname> that compiles in full debug mode +# and is not added to the test target. The idea is that when a test fails you want +# a quick way of rebuilding this specific test in full debug mode. +# +# On platforms with bash simply run: +# "ctest -V" or "ctest -V -R <testname>" +# On other platform use ctest as usual +# +macro(ei_add_test testname) + ei_add_test_internal(${testname} ${testname} "${ARGV1}" "${ARGV2}") endmacro(ei_add_test) +# Macro to add a multi-part test. Allows to split large tests into multiple executables. +# +# The first parameter is the number of parts. +# +# the second parameter testname must correspond to a file +# <testname>.cpp which follows this pattern: +# +# #include "main.h" +# void test_<testname>() { ... } +# +# this macro adds executables test_<testname>_N for N ranging from 1 to the number of parts +# (first parameter) as well as corresponding ctest tests named <testname_N>. +# +# it also adds corresponding debug targets and ctest tests, see the documentation of ei_add_test. +# +# On platforms with bash simply run: +# "ctest -V" or "ctest -V -R <testname>" +# On other platforms use ctest as usual +macro(ei_add_test_multi parts testname) + if(EIGEN_SPLIT_LARGE_TESTS) + add_custom_target(test_${testname}) + if(NOT MSVC_IDE) + add_custom_target(debug_${testname}) + endif(NOT MSVC_IDE) + foreach(part RANGE 1 ${parts}) + message("multipart argv2 ${ARGV2} argv3 ${ARGV3}") + ei_add_test_internal(${testname} ${testname}_${part} "${ARGV2} -DEIGEN_TEST_PART_${part}" "${ARGV3}") + add_dependencies(test_${testname} test_${testname}_${part}) + if(NOT MSVC_IDE) + add_dependencies(debug_${testname} debug_${testname}_${part}) + endif(NOT MSVC_IDE) + endforeach(part) + else(EIGEN_SPLIT_LARGE_TESTS) + set(symbols_to_enable_all_parts "") + foreach(part RANGE 1 ${parts}) + set(symbols_to_enable_all_parts "${symbols_to_enable_all_parts} -DEIGEN_TEST_PART_${part}") + endforeach(part) + ei_add_test_internal(${testname} ${testname} "${ARGV2} ${symbols_to_enable_all_parts}" "${ARGV3}") + endif(EIGEN_SPLIT_LARGE_TESTS) +endmacro(ei_add_test_multi) + # print a summary of the different options macro(ei_testing_print_summary) @@ -204,12 +254,15 @@ if(CMAKE_COMPILER_IS_GNUCXX) 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 -g2") + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${COVERAGE_FLAGS} -O0 -g3") endif(CMAKE_SYSTEM_NAME MATCHES Linux) set(EI_OFLAG "-O2") + set(EI_NO_OPTIMIZATION_FLAG "-O0") elseif(MSVC) set(CMAKE_CXX_FLAGS_DEBUG "/D_DEBUG /MDd /Zi /Ob0 /Od" CACHE STRING "Flags used by the compiler during debug builds." FORCE) set(EI_OFLAG "/O2") + set(EI_NO_OPTIMIZATION_FLAG "/O0") else(CMAKE_COMPILER_IS_GNUCXX) set(EI_OFLAG "") + set(EI_NO_OPTIMIZATION_FLAG "") endif(CMAKE_COMPILER_IS_GNUCXX) |