From 661a157553d46826d16da1201d638741211fd737 Mon Sep 17 00:00:00 2001 From: Richard Roberts Date: Thu, 13 Feb 2014 01:34:31 -0500 Subject: [PATCH] Working on standardizing/simplifying building unit tests and examples. Much simpler cmake function to add a glob of tests, doing away with convenience libraries, and removing other options that we never change from their defaults. --- CMakeLists.txt | 5 +- cmake/GtsamTesting.cmake | 109 +++++++++++++++++- gtsam/base/CMakeLists.txt | 10 +- gtsam/base/tests/CMakeLists.txt | 1 + gtsam/discrete/CMakeLists.txt | 7 +- gtsam/discrete/tests/CMakeLists.txt | 1 + gtsam/geometry/CMakeLists.txt | 10 +- gtsam/geometry/tests/CMakeLists.txt | 1 + gtsam/inference/CMakeLists.txt | 10 +- gtsam/inference/tests/CMakeLists.txt | 1 + gtsam/linear/CMakeLists.txt | 15 +-- gtsam/linear/tests/CMakeLists.txt | 6 + gtsam/navigation/CMakeLists.txt | 7 +- gtsam/navigation/tests/CMakeLists.txt | 1 + gtsam/nonlinear/CMakeLists.txt | 10 +- gtsam/nonlinear/tests/CMakeLists.txt | 1 + gtsam/slam/CMakeLists.txt | 11 +- gtsam/slam/tests/CMakeLists.txt | 6 + gtsam/symbolic/CMakeLists.txt | 10 +- gtsam/symbolic/tests/CMakeLists.txt | 1 + gtsam_unstable/base/CMakeLists.txt | 10 +- gtsam_unstable/base/tests/CMakeLists.txt | 1 + gtsam_unstable/discrete/CMakeLists.txt | 13 +-- gtsam_unstable/discrete/tests/CMakeLists.txt | 1 + gtsam_unstable/dynamics/CMakeLists.txt | 11 +- gtsam_unstable/dynamics/tests/CMakeLists.txt | 1 + gtsam_unstable/geometry/CMakeLists.txt | 11 +- gtsam_unstable/geometry/tests/CMakeLists.txt | 1 + gtsam_unstable/nonlinear/CMakeLists.txt | 15 +-- gtsam_unstable/nonlinear/tests/CMakeLists.txt | 1 + gtsam_unstable/slam/CMakeLists.txt | 13 +-- gtsam_unstable/slam/tests/CMakeLists.txt | 7 ++ tests/CMakeLists.txt | 31 ++--- wrap/CMakeLists.txt | 6 +- wrap/tests/CMakeLists.txt | 1 + 35 files changed, 164 insertions(+), 182 deletions(-) create mode 100644 gtsam/base/tests/CMakeLists.txt create mode 100644 gtsam/discrete/tests/CMakeLists.txt create mode 100644 gtsam/geometry/tests/CMakeLists.txt create mode 100644 gtsam/inference/tests/CMakeLists.txt create mode 100644 gtsam/linear/tests/CMakeLists.txt create mode 100644 gtsam/navigation/tests/CMakeLists.txt create mode 100644 gtsam/nonlinear/tests/CMakeLists.txt create mode 100644 gtsam/slam/tests/CMakeLists.txt create mode 100644 gtsam/symbolic/tests/CMakeLists.txt create mode 100644 gtsam_unstable/base/tests/CMakeLists.txt create mode 100644 gtsam_unstable/discrete/tests/CMakeLists.txt create mode 100644 gtsam_unstable/dynamics/tests/CMakeLists.txt create mode 100644 gtsam_unstable/geometry/tests/CMakeLists.txt create mode 100644 gtsam_unstable/nonlinear/tests/CMakeLists.txt create mode 100644 gtsam_unstable/slam/tests/CMakeLists.txt create mode 100644 wrap/tests/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 337fd19a4..22e58564b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,7 +46,6 @@ endif() # Set up options # Configurable Options -option(GTSAM_BUILD_TESTS "Enable/Disable building of tests" ON) option(GTSAM_BUILD_TIMING "Enable/Disable building of timing scripts" OFF) # These do not currently work option(GTSAM_BUILD_EXAMPLES "Enable/Disable building of examples" ON) if(GTSAM_UNSTABLE_AVAILABLE) @@ -83,9 +82,8 @@ endif() set(CPACK_SOURCE_GENERATOR "TGZ" CACHE STRING "CPack Default Source Generator") set(CPACK_GENERATOR "TGZ" CACHE STRING "CPack Default Binary Generator") -# Flags to determine whether tests and examples are build during 'make install' +# Flags to determine whether examples are build during 'make install' # Note that these remove the targets from the 'all' -option(GTSAM_DISABLE_TESTS_ON_INSTALL "Disables building tests during install" ON) option(GTSAM_DISABLE_EXAMPLES_ON_INSTALL "Disables building examples during install" OFF) # Pull in infrastructure @@ -375,7 +373,6 @@ print_config_flag(${GTSAM_BUILD_TYPE_POSTFIXES} "Put build type in librar if(GTSAM_UNSTABLE_AVAILABLE) print_config_flag(${GTSAM_BUILD_UNSTABLE} "Build libgtsam_unstable ") endif() -print_config_flag(${GTSAM_DISABLE_TESTS_ON_INSTALL} "No tests in all or install ") print_config_flag(${GTSAM_DISABLE_EXAMPLES_ON_INSTALL} "No examples in all or install ") string(TOUPPER "${CMAKE_BUILD_TYPE}" cmake_build_type_toupper) if(NOT MSVC AND NOT XCODE_VERSION) diff --git a/cmake/GtsamTesting.cmake b/cmake/GtsamTesting.cmake index f1b7c5e54..dce09449e 100644 --- a/cmake/GtsamTesting.cmake +++ b/cmake/GtsamTesting.cmake @@ -2,8 +2,13 @@ enable_testing() +option(GTSAM_BUILD_TESTS "Enable/Disable building of tests" ON) + # Enable make check (http://www.cmake.org/Wiki/CMakeEmulateMakeCheck) -add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} -C $ --output-on-failure) +if(GTSAM_BUILD_TESTS) + add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} -C $ --output-on-failure) +endif() + add_custom_target(timing) # Add option for combining unit tests @@ -13,6 +18,108 @@ else() option(GTSAM_SINGLE_TEST_EXE "Combine unit tests into single executable (faster compile)" OFF) endif() +# Macro for adding glob(s) of tests relative to the current directory. Automatically +# links the tests with CppUnitLite. Separate multiple globPatterns, linkLibraries, +# and excludedFiles using a semicolon, e.g. "testThings*.cpp;testOthers*.cpp". +# Usage example: gtsamAddTestsGlob(basic "test*.cpp" "testBroken.cpp" "gtsam;GeographicLib") +macro(gtsamAddTestsGlob groupName globPatterns excludedFiles linkLibraries) + if(GTSAM_BUILD_TESTS) + # Add group target if it doesn't already exist + if(NOT TARGET check.${groupName}) + add_custom_target(check.${groupName} COMMAND ${CMAKE_CTEST_COMMAND} -C $ --output-on-failure) + endif() + + # Get all script files relative to the currect directory + set(script_files_relative "") + foreach(one_pattern IN ITEMS ${globPatterns}) + message(STATUS "Filling test group ${groupName}") + file(GLOB RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} one_script_files "${one_pattern}") + list(APPEND script_files_relative "${one_script_files}") + endforeach() + + # Remove excluded scripts from the list + if(excludedFiles) + list(REMOVE_ITEM script_files_relative excludedFiles) + endif() + + # Get absolute paths + set(script_files "") + foreach(script_file IN ITEMS ${script_files_relative}) + list(APPEND script_files "${CMAKE_CURRENT_SOURCE_DIR}/${script_file}") + endforeach() + + # Separate into source files and headers (allows for adding headers to show up in + # MSVC and Xcode projects). + set(script_srcs "") + set(script_headers "") + foreach(script_file IN ITEMS ${script_files}) + get_filename_component(script_ext ${script_file} EXT) + if(script_ext MATCHES "(h|H)") + list(APPEND script_headers ${script_file}) + else() + list(APPEND script_srcs ${script_file}) + endif() + endforeach() + + # Don't put test files in folders in MSVC and Xcode because they're already grouped + source_group("" FILES ${script_srcs} ${script_headers}) + + if(NOT GTSAM_SINGLE_TEST_EXE) + foreach(script_src IN ITEMS ${script_srcs}) + # Get test base name + get_filename_component(script_name ${script_src} NAME_WE) + + # Add executable + add_executable(script_name ${script_src} ${script_headers}) + target_link_libraries(${script_name} CppUnitLite ${linkLibraries}) + + # Add target dependencies + add_test(NAME ${script_name} COMMAND ${script_name}) + add_dependencies(check.${groupName} ${script_name}) + add_dependencies(check ${script_name}) + if(NOT MSVC AND NOT XCODE_VERSION) + add_custom_target(${script_name}.run ${EXECUTABLE_OUTPUT_PATH}${script_name}) + endif() + + # Add TOPSRCDIR + set_property(SOURCE ${script_src} APPEND PROPERTY COMPILE_DEFINITIONS "TOPSRCDIR=\"${PROJECT_SOURCE_DIR}\"") + + # Exclude from 'make all' and 'make install' + set_target_properties(${script_name} PROPERTIES EXCLUDE_FROM_ALL ON) + + # Configure target folder (for MSVC and Xcode) + set_property(TARGET ${script_name} PROPERTY FOLDER "Unit tests/${groupName}") + endforeach() + else() + # Create single unit test exe from all test scripts + set(target_name check_${groupName}_program) + + # Add executable + add_executable(${target_name} ${script_srcs} ${script_headers}) + target_link_libraries(${target_name} CppUnitLite ${linkLibraries}) + + # Only have a main function in one script - use preprocessor + set(rest_script_srcs ${script_srcs}) + list(REMOVE_AT rest_script_srcs 0) + set_property(SOURCE ${rest_script_srcs} APPEND PROPERTY COMPILE_DEFINITIONS "main=static no_main") + + # Add target dependencies + add_test(NAME ${target_name} COMMAND ${target_name}) + add_dependencies(check.${groupName} ${target_name}) + add_dependencies(check ${target_name}) + + # Add TOPSRCDIR + set_property(SOURCE ${script_srcs} APPEND PROPERTY COMPILE_DEFINITIONS "TOPSRCDIR=\"${PROJECT_SOURCE_DIR}\"") + + # Excluse from 'make all' and 'make install' + set_target_properties(${target_name} PROPERTIES EXCLUDE_FROM_ALL ON) + + # Configure target folder (for MSVC and Xcode) + set_property(TARGET ${script_name} PROPERTY FOLDER "Unit tests") + endif() + endif() +endmacro() + # Macro for adding categorized tests in a "tests" folder, with # optional exclusion of tests and convenience library linking options # diff --git a/gtsam/base/CMakeLists.txt b/gtsam/base/CMakeLists.txt index 94e2473ed..50145846e 100644 --- a/gtsam/base/CMakeLists.txt +++ b/gtsam/base/CMakeLists.txt @@ -5,16 +5,8 @@ install(FILES ${base_headers} DESTINATION include/gtsam/base) file(GLOB base_headers_tree "treeTraversal/*.h") install(FILES ${base_headers_tree} DESTINATION include/gtsam/base/treeTraversal) -# Files to exclude from compilation of tests and timing scripts -set(base_excluded_files -# "${CMAKE_CURRENT_SOURCE_DIR}/tests/testTypedDiscreteFactor.cpp" # Example of excluding a test -# "" # Add to this list, with full path, to exclude -) - # Build tests -if (GTSAM_BUILD_TESTS) - gtsam_add_subdir_tests(base "gtsam" "gtsam" "${base_excluded_files}") -endif(GTSAM_BUILD_TESTS) +add_subdirectory(tests) # Build timing scripts if (GTSAM_BUILD_TIMING) diff --git a/gtsam/base/tests/CMakeLists.txt b/gtsam/base/tests/CMakeLists.txt new file mode 100644 index 000000000..8e99ef5ba --- /dev/null +++ b/gtsam/base/tests/CMakeLists.txt @@ -0,0 +1 @@ +gtsamAddTestsGlob(base "test*.cpp" "" "gtsam") diff --git a/gtsam/discrete/CMakeLists.txt b/gtsam/discrete/CMakeLists.txt index 3f1a57e0b..3c5602080 100644 --- a/gtsam/discrete/CMakeLists.txt +++ b/gtsam/discrete/CMakeLists.txt @@ -4,13 +4,8 @@ file(GLOB discrete_headers "*.h") # FIXME: exclude headers install(FILES ${discrete_headers} DESTINATION include/gtsam/discrete) -# Exclude tests that don't work -set (discrete_excluded_tests "") - # Add all tests -if (GTSAM_BUILD_TESTS) - gtsam_add_subdir_tests(discrete "gtsam" "gtsam" "${discrete_excluded_tests}") -endif() +add_subdirectory(tests) # Build timing scripts #if (GTSAM_BUILD_TIMING) diff --git a/gtsam/discrete/tests/CMakeLists.txt b/gtsam/discrete/tests/CMakeLists.txt new file mode 100644 index 000000000..e968fac91 --- /dev/null +++ b/gtsam/discrete/tests/CMakeLists.txt @@ -0,0 +1 @@ +gtsamAddTestsGlob(discrete "test*.cpp" "" "gtsam") diff --git a/gtsam/geometry/CMakeLists.txt b/gtsam/geometry/CMakeLists.txt index 96b84193b..f72f965ea 100644 --- a/gtsam/geometry/CMakeLists.txt +++ b/gtsam/geometry/CMakeLists.txt @@ -2,16 +2,8 @@ file(GLOB geometry_headers "*.h") install(FILES ${geometry_headers} DESTINATION include/gtsam/geometry) -# Files to exclude from compilation of tests and timing scripts -set(geometry_excluded_files -# "${CMAKE_CURRENT_SOURCE_DIR}/tests/testTypedDiscreteFactor.cpp" # Example of excluding a test - "" # Add to this list, with full path, to exclude -) - # Build tests -if (GTSAM_BUILD_TESTS) - gtsam_add_subdir_tests(geometry "gtsam" "gtsam" "${geometry_excluded_files}") -endif(GTSAM_BUILD_TESTS) +add_subdirectory(tests) # Build timing scripts if (GTSAM_BUILD_TIMING) diff --git a/gtsam/geometry/tests/CMakeLists.txt b/gtsam/geometry/tests/CMakeLists.txt new file mode 100644 index 000000000..b1499ee9d --- /dev/null +++ b/gtsam/geometry/tests/CMakeLists.txt @@ -0,0 +1 @@ +gtsamAddTestsGlob(geometry "test*.cpp" "" "gtsam") diff --git a/gtsam/inference/CMakeLists.txt b/gtsam/inference/CMakeLists.txt index d5c994b00..d5c37d976 100644 --- a/gtsam/inference/CMakeLists.txt +++ b/gtsam/inference/CMakeLists.txt @@ -2,16 +2,8 @@ file(GLOB inference_headers "*.h") install(FILES ${inference_headers} DESTINATION include/gtsam/inference) -# Files to exclude from compilation of tests and timing scripts -set(inference_excluded_files -# "${CMAKE_CURRENT_SOURCE_DIR}/tests/testTypedDiscreteFactor.cpp" # Example of excluding a test - "" # Add to this list, with full path, to exclude -) - # Build tests -if (GTSAM_BUILD_TESTS) - gtsam_add_subdir_tests(inference "gtsam" "gtsam" "${inference_excluded_files}") -endif(GTSAM_BUILD_TESTS) +add_subdirectory(tests) # Build timing scripts if (GTSAM_BUILD_TIMING) diff --git a/gtsam/inference/tests/CMakeLists.txt b/gtsam/inference/tests/CMakeLists.txt new file mode 100644 index 000000000..aaa01d775 --- /dev/null +++ b/gtsam/inference/tests/CMakeLists.txt @@ -0,0 +1 @@ +gtsamAddTestsGlob(inference "test*.cpp" "" "gtsam") diff --git a/gtsam/linear/CMakeLists.txt b/gtsam/linear/CMakeLists.txt index 4a93e2875..29eb60b93 100644 --- a/gtsam/linear/CMakeLists.txt +++ b/gtsam/linear/CMakeLists.txt @@ -2,21 +2,8 @@ file(GLOB linear_headers "*.h") install(FILES ${linear_headers} DESTINATION include/gtsam/linear) -# Files to exclude from compilation of tests and timing scripts -set(linear_excluded_files -# "${CMAKE_CURRENT_SOURCE_DIR}/tests/testTypedDiscreteFactor.cpp" # Example of excluding a test -# "" # Add to this list, with full path, to exclude -) - # Build tests -if (GTSAM_BUILD_TESTS) - gtsam_add_subdir_tests(linear "gtsam" "gtsam" "${linear_excluded_files}") -endif(GTSAM_BUILD_TESTS) - -if(MSVC) - set_property(SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/tests/testSerializationLinear.cpp" - APPEND PROPERTY COMPILE_FLAGS "/bigobj") -endif() +add_subdirectory(tests) # Build timing scripts if (GTSAM_BUILD_TIMING) diff --git a/gtsam/linear/tests/CMakeLists.txt b/gtsam/linear/tests/CMakeLists.txt new file mode 100644 index 000000000..d1aafb4ea --- /dev/null +++ b/gtsam/linear/tests/CMakeLists.txt @@ -0,0 +1,6 @@ +gtsamAddTestsGlob(linear "test*.cpp" "" "gtsam") + +if(MSVC) + set_property(SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/testSerializationLinear.cpp" + APPEND PROPERTY COMPILE_FLAGS "/bigobj") +endif() diff --git a/gtsam/navigation/CMakeLists.txt b/gtsam/navigation/CMakeLists.txt index ed599cf15..3e82af774 100644 --- a/gtsam/navigation/CMakeLists.txt +++ b/gtsam/navigation/CMakeLists.txt @@ -2,13 +2,8 @@ file(GLOB navigation_headers "*.h") install(FILES ${navigation_headers} DESTINATION include/gtsam/navigation) -# Exclude tests that don't work -set (navigation_excluded_tests "") - # Add all tests -if (GTSAM_BUILD_TESTS) - gtsam_add_subdir_tests(navigation "gtsam" "gtsam" "${navigation_excluded_tests}") -endif() +add_subdirectory(tests) # Build timing scripts if (GTSAM_BUILD_TIMING) diff --git a/gtsam/navigation/tests/CMakeLists.txt b/gtsam/navigation/tests/CMakeLists.txt new file mode 100644 index 000000000..4fd0b00d0 --- /dev/null +++ b/gtsam/navigation/tests/CMakeLists.txt @@ -0,0 +1 @@ +gtsamAddTestsGlob(navigation "test*.cpp" "" "gtsam") diff --git a/gtsam/nonlinear/CMakeLists.txt b/gtsam/nonlinear/CMakeLists.txt index f4cf0b585..b4d288104 100644 --- a/gtsam/nonlinear/CMakeLists.txt +++ b/gtsam/nonlinear/CMakeLists.txt @@ -2,16 +2,8 @@ file(GLOB nonlinear_headers "*.h") install(FILES ${nonlinear_headers} DESTINATION include/gtsam/nonlinear) -# Files to exclude from compilation of tests and timing scripts -set(nonlinear_excluded_files -# "${CMAKE_CURRENT_SOURCE_DIR}/tests/testTypedDiscreteFactor.cpp" # Example of excluding a test - "" # Add to this list, with full path, to exclude -) - # Build tests -if (GTSAM_BUILD_TESTS) - gtsam_add_subdir_tests(nonlinear "gtsam" "gtsam" "${nonlinear_excluded_files}") -endif(GTSAM_BUILD_TESTS) +add_subdirectory(tests) # Build timing scripts if (GTSAM_BUILD_TIMING) diff --git a/gtsam/nonlinear/tests/CMakeLists.txt b/gtsam/nonlinear/tests/CMakeLists.txt new file mode 100644 index 000000000..69a3700f2 --- /dev/null +++ b/gtsam/nonlinear/tests/CMakeLists.txt @@ -0,0 +1 @@ +gtsamAddTestsGlob(nonlinear "test*.cpp" "" "gtsam") diff --git a/gtsam/slam/CMakeLists.txt b/gtsam/slam/CMakeLists.txt index 1c20e3720..b348c4aa3 100644 --- a/gtsam/slam/CMakeLists.txt +++ b/gtsam/slam/CMakeLists.txt @@ -4,19 +4,10 @@ set (slam_excluded_headers #"") ) file(GLOB slam_headers "*.h") -list(REMOVE_ITEM slam_headers ${slam_excluded_headers}) install(FILES ${slam_headers} DESTINATION include/gtsam/slam) -# Files to exclude from compilation of tests and timing scripts -set(slam_excluded_files - "${CMAKE_CURRENT_SOURCE_DIR}/tests/testSerialization.cpp" -# "" # Add to this list, with full path, to exclude -) - # Build tests -if (GTSAM_BUILD_TESTS) - gtsam_add_subdir_tests(slam "gtsam" "gtsam" "${slam_excluded_files}") -endif(GTSAM_BUILD_TESTS) +add_subdirectory(tests) # Build timing scripts if (GTSAM_BUILD_TIMING) diff --git a/gtsam/slam/tests/CMakeLists.txt b/gtsam/slam/tests/CMakeLists.txt new file mode 100644 index 000000000..d59128c2f --- /dev/null +++ b/gtsam/slam/tests/CMakeLists.txt @@ -0,0 +1,6 @@ +# Files to exclude +set(slam_excluded_files + testSerialization.cpp +) + +gtsamAddTestsGlob(slam "test*.cpp" "${slam_excluded_files}" "gtsam") diff --git a/gtsam/symbolic/CMakeLists.txt b/gtsam/symbolic/CMakeLists.txt index a683f0711..6535755f8 100644 --- a/gtsam/symbolic/CMakeLists.txt +++ b/gtsam/symbolic/CMakeLists.txt @@ -2,16 +2,8 @@ file(GLOB symbolic_headers "*.h") install(FILES ${symbolic_headers} DESTINATION include/gtsam/symbolic) -# Files to exclude from compilation of tests and timing scripts -set(symbolic_excluded_files -# "${CMAKE_CURRENT_SOURCE_DIR}/tests/testTypedDiscreteFactor.cpp" # Example of excluding a test - "" # Add to this list, with full path, to exclude -) - # Build tests -if (GTSAM_BUILD_TESTS) - gtsam_add_subdir_tests(symbolic "gtsam" "gtsam" "${symbolic_excluded_files}") -endif(GTSAM_BUILD_TESTS) +add_subdirectory(tests) # Build timing scripts if (GTSAM_BUILD_TIMING) diff --git a/gtsam/symbolic/tests/CMakeLists.txt b/gtsam/symbolic/tests/CMakeLists.txt new file mode 100644 index 000000000..6bef7a109 --- /dev/null +++ b/gtsam/symbolic/tests/CMakeLists.txt @@ -0,0 +1 @@ +gtsamAddTestsGlob(symbolic "test*.cpp" "" "gtsam") diff --git a/gtsam_unstable/base/CMakeLists.txt b/gtsam_unstable/base/CMakeLists.txt index 22737d533..d83e97d26 100644 --- a/gtsam_unstable/base/CMakeLists.txt +++ b/gtsam_unstable/base/CMakeLists.txt @@ -2,16 +2,8 @@ file(GLOB base_headers "*.h") install(FILES ${base_headers} DESTINATION include/gtsam_unstable/base) -set (base_full_libs - gtsam - gtsam_unstable) - -# Exclude tests that don't work -set (base_excluded_tests "") - # Add all tests -gtsam_add_subdir_tests(base_unstable "${base_full_libs}" "${base_full_libs}" "${base_excluded_tests}") -add_dependencies(check.unstable check.base_unstable) +add_subdirectory(tests) # Build timing scripts if (GTSAM_BUILD_TIMING) diff --git a/gtsam_unstable/base/tests/CMakeLists.txt b/gtsam_unstable/base/tests/CMakeLists.txt new file mode 100644 index 000000000..d103ec578 --- /dev/null +++ b/gtsam_unstable/base/tests/CMakeLists.txt @@ -0,0 +1 @@ +gtsamAddTestsGlob(base_unstable "test*.cpp" "" "gtsam_unstable") diff --git a/gtsam_unstable/discrete/CMakeLists.txt b/gtsam_unstable/discrete/CMakeLists.txt index f6cfcb1a8..1072999b2 100644 --- a/gtsam_unstable/discrete/CMakeLists.txt +++ b/gtsam_unstable/discrete/CMakeLists.txt @@ -2,19 +2,8 @@ file(GLOB discrete_headers "*.h") install(FILES ${discrete_headers} DESTINATION include/gtsam_unstable/discrete) -set (discrete_full_libs - gtsam - gtsam_unstable) - -# Exclude tests that don't work -#set (discrete_excluded_tests -#"${CMAKE_CURRENT_SOURCE_DIR}/tests/testScheduler.cpp" -#) - - # Add all tests -gtsam_add_subdir_tests(discrete_unstable "${discrete_full_libs}" "${discrete_full_libs}" "${discrete_excluded_tests}") -add_dependencies(check.unstable check.discrete_unstable) +add_subdirectory(tests) # List examples to build - comment out here to exclude from compilation set(discrete_unstable_examples diff --git a/gtsam_unstable/discrete/tests/CMakeLists.txt b/gtsam_unstable/discrete/tests/CMakeLists.txt new file mode 100644 index 000000000..2687a760c --- /dev/null +++ b/gtsam_unstable/discrete/tests/CMakeLists.txt @@ -0,0 +1 @@ +gtsamAddTestsGlob(discrete_unstable "test*.cpp" "" "gtsam_unstable") diff --git a/gtsam_unstable/dynamics/CMakeLists.txt b/gtsam_unstable/dynamics/CMakeLists.txt index 382b2b4cf..66aef9455 100644 --- a/gtsam_unstable/dynamics/CMakeLists.txt +++ b/gtsam_unstable/dynamics/CMakeLists.txt @@ -2,14 +2,5 @@ file(GLOB dynamics_headers "*.h") install(FILES ${dynamics_headers} DESTINATION include/gtsam_unstable/dynamics) -# Components to link tests in this subfolder against -set (dynamics_full_libs - gtsam - gtsam_unstable) - -# Exclude tests that don't work -set (dynamics_excluded_tests "") - # Add all tests -gtsam_add_subdir_tests(dynamics_unstable "${dynamics_full_libs}" "${dynamics_full_libs}" "${dynamics_excluded_tests}") -add_dependencies(check.unstable check.dynamics_unstable) +add_subdirectory(tests) diff --git a/gtsam_unstable/dynamics/tests/CMakeLists.txt b/gtsam_unstable/dynamics/tests/CMakeLists.txt new file mode 100644 index 000000000..493cef4fa --- /dev/null +++ b/gtsam_unstable/dynamics/tests/CMakeLists.txt @@ -0,0 +1 @@ +gtsamAddTestsGlob(dynamics_unstable "test*.cpp" "" "gtsam_unstable") diff --git a/gtsam_unstable/geometry/CMakeLists.txt b/gtsam_unstable/geometry/CMakeLists.txt index c7ee3902f..c8b7e250f 100644 --- a/gtsam_unstable/geometry/CMakeLists.txt +++ b/gtsam_unstable/geometry/CMakeLists.txt @@ -2,14 +2,5 @@ file(GLOB geometry_headers "*.h") install(FILES ${geometry_headers} DESTINATION include/gtsam_unstable/geometry) -# Components to link tests in this subfolder against -set (geometry_full_libs - gtsam - gtsam_unstable) - -# Exclude tests that don't work -set (geometry_excluded_tests "") - # Add all tests -gtsam_add_subdir_tests(geometry_unstable "${geometry_full_libs}" "${geometry_full_libs}" "${geometry_excluded_tests}") -add_dependencies(check.unstable check.geometry_unstable) +add_subdirectory(tests) diff --git a/gtsam_unstable/geometry/tests/CMakeLists.txt b/gtsam_unstable/geometry/tests/CMakeLists.txt new file mode 100644 index 000000000..e22da8652 --- /dev/null +++ b/gtsam_unstable/geometry/tests/CMakeLists.txt @@ -0,0 +1 @@ +gtsamAddTestsGlob(geometry_unstable "test*.cpp" "" "gtsam_unstable") diff --git a/gtsam_unstable/nonlinear/CMakeLists.txt b/gtsam_unstable/nonlinear/CMakeLists.txt index daef8983c..9e0cb68e1 100644 --- a/gtsam_unstable/nonlinear/CMakeLists.txt +++ b/gtsam_unstable/nonlinear/CMakeLists.txt @@ -2,18 +2,5 @@ file(GLOB nonlinear_headers "*.h") install(FILES ${nonlinear_headers} DESTINATION include/gtsam_unstable/nonlinear) -# Components to link tests in this subfolder against -set (nonlinear_full_libs -gtsam -gtsam_unstable) - -# Exclude tests that don't work -set (nonlinear_excluded_tests #"") -#"${CMAKE_CURRENT_SOURCE_DIR}/tests/testConcurrentIncrementalFilter.cpp" -#"${CMAKE_CURRENT_SOURCE_DIR}/tests/testIncrementalFixedLagSmoother.cpp" -) - - # Add all tests -gtsam_add_subdir_tests(nonlinear_unstable "${nonlinear_full_libs}" "${nonlinear_full_libs}" "${nonlinear_excluded_tests}") -add_dependencies(check.unstable check.nonlinear_unstable) +add_subdirectory(tests) diff --git a/gtsam_unstable/nonlinear/tests/CMakeLists.txt b/gtsam_unstable/nonlinear/tests/CMakeLists.txt new file mode 100644 index 000000000..5b1fd07d4 --- /dev/null +++ b/gtsam_unstable/nonlinear/tests/CMakeLists.txt @@ -0,0 +1 @@ +gtsamAddTestsGlob(nonlinear_unstable "test*.cpp" "" "gtsam_unstable") diff --git a/gtsam_unstable/slam/CMakeLists.txt b/gtsam_unstable/slam/CMakeLists.txt index ae4784f70..a86beac63 100644 --- a/gtsam_unstable/slam/CMakeLists.txt +++ b/gtsam_unstable/slam/CMakeLists.txt @@ -7,16 +7,5 @@ file(GLOB slam_headers "*.h") list(REMOVE_ITEM slam_headers ${slam_excluded_headers}) install(FILES ${slam_headers} DESTINATION include/gtsam_unstable/slam) -# Components to link tests in this subfolder against -set (slam_full_libs - gtsam - gtsam_unstable) - -# Exclude tests that don't work -set (slam_excluded_tests - "${CMAKE_CURRENT_SOURCE_DIR}/tests/testSerialization.cpp" -# "" # Add to this list, with full path, to exclude -) # Add all tests -gtsam_add_subdir_tests(slam_unstable "${slam_full_libs}" "${slam_full_libs}" "${slam_excluded_tests}") -add_dependencies(check.unstable check.slam_unstable) +add_subdirectory(tests) diff --git a/gtsam_unstable/slam/tests/CMakeLists.txt b/gtsam_unstable/slam/tests/CMakeLists.txt new file mode 100644 index 000000000..bb5259ef2 --- /dev/null +++ b/gtsam_unstable/slam/tests/CMakeLists.txt @@ -0,0 +1,7 @@ + +# Exclude tests that don't work +set (slam_excluded_tests + testSerialization.cpp +) + +gtsamAddTestsGlob(slam_unstable "test*.cpp" "${slam_excluded_tests}" "gtsam_unstable") diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index a6ae2afca..cf81dc762 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,31 +1,19 @@ -# Assemble local libraries -set (tests_full_libs - gtsam - CppUnitLite) - # exclude certain files # note the source dir on each -set (tests_exclude - #"${CMAKE_CURRENT_SOURCE_DIR}/testOccupancyGrid.cpp" -) +set (tests_exclude "") if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") # might not be best test - Richard & Jason & Frank # clang linker segfaults on large testSerializationSLAM - list (APPEND tests_exclude "${CMAKE_CURRENT_SOURCE_DIR}/testSerializationSLAM.cpp") + list (APPEND tests_exclude "testSerializationSLAM.cpp") endif() # Build tests -if (GTSAM_BUILD_TESTS) - # Subdirectory target for tests - add_custom_target(check.tests COMMAND ${CMAKE_CTEST_COMMAND}) - set(is_test TRUE) +gtsamAddTestsGlob(tests "test*.cpp" "${tests_exclude}" "gtsam") - # Build grouped tests - gtsam_add_grouped_scripts("tests" # Use subdirectory as group label - "test*.cpp;*.h" check "Test" # Standard for all tests - "${tests_full_libs}" "${tests_full_libs}" "${tests_exclude}" # Pass in linking and exclusion lists - ${is_test}) # Set all as tests -endif (GTSAM_BUILD_TESTS) +if(MSVC) + set_property(SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/testSerializationSLAM.cpp" + APPEND PROPERTY COMPILE_FLAGS "/bigobj") +endif() # Build timing scripts if (GTSAM_BUILD_TIMING) @@ -39,8 +27,3 @@ if (GTSAM_BUILD_TIMING) "${tests_full_libs}" "${tests_full_libs}" "${tests_exclude}" # Pass in linking and exclusion lists ${is_test}) endif (GTSAM_BUILD_TIMING) - -if(MSVC) - set_property(SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/testSerializationSLAM.cpp" - APPEND PROPERTY COMPILE_FLAGS "/bigobj") -endif() diff --git a/wrap/CMakeLists.txt b/wrap/CMakeLists.txt index 28f8bea48..03915a662 100644 --- a/wrap/CMakeLists.txt +++ b/wrap/CMakeLists.txt @@ -31,9 +31,5 @@ set(GTSAM_EXPORTED_TARGETS "${GTSAM_EXPORTED_TARGETS}" PARENT_SCOPE) install(FILES matlab.h DESTINATION include/wrap) # Build tests -if (GTSAM_BUILD_TESTS) - set(wrap_local_libs wrap_lib ${WRAP_BOOST_LIBRARIES}) - gtsam_add_subdir_tests("wrap" "${wrap_local_libs}" "${wrap_local_libs}" "") -endif(GTSAM_BUILD_TESTS) - +add_subdirectory(tests) diff --git a/wrap/tests/CMakeLists.txt b/wrap/tests/CMakeLists.txt new file mode 100644 index 000000000..f3ac1df49 --- /dev/null +++ b/wrap/tests/CMakeLists.txt @@ -0,0 +1 @@ +gtsamAddTestsGlob(wrap "test*.cpp" "" "wrap_lib")