diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 02b4d455e..cafef8148 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,16 +1,11 @@ -if (GTSAM_BUILD_CONVENIENCE_LIBRARIES) - set(convenience_libs - slam - nonlinear - linear - inference - geometry - base - ccolamd) -else (GTSAM_BUILD_CONVENIENCE_LIBRARIES) - set(convenience_libs - gtsam-static) -endif (GTSAM_BUILD_CONVENIENCE_LIBRARIES) +set(tests_local_libs + slam + nonlinear + linear + inference + geometry + base + ccolamd) # exclude certain files # note the source dir on each @@ -20,35 +15,26 @@ set (tests_exclude # Build tests if (GTSAM_BUILD_TESTS) + # Subdirectory target for tests add_custom_target(check.tests COMMAND ${CMAKE_CTEST_COMMAND}) - file(GLOB tests_srcs "test*.cpp") - list(REMOVE_ITEM tests_srcs ${tests_exclude}) - foreach(test_src ${tests_srcs}) - get_filename_component(test_base ${test_src} NAME_WE) - set( test_bin ${test_base} ) - message(STATUS "Adding Test ${test_bin}") - add_executable(${test_bin} ${test_src}) - add_dependencies(check.tests ${test_bin}) - add_dependencies(check ${test_bin}) - add_test(${test_base} ${EXECUTABLE_OUTPUT_PATH}${test_bin}) - target_link_libraries(${test_bin} ${convenience_libs} CppUnitLite ${Boost_LIBRARIES}) - add_custom_target(${test_bin}.run ${EXECUTABLE_OUTPUT_PATH}${test_bin} ${ARGN}) - endforeach(test_src) + set(is_test TRUE) + + # Build grouped tests + gtsam_add_grouped_scripts("tests" # Use subdirectory as group label + "test*.cpp" check "Test" # Standard for all tests + "${tests_local_libs}" "gtsam-static" "${tests_exclude}" # Pass in linking and exclusion lists + ${is_test}) # Set all as tests endif (GTSAM_BUILD_TESTS) # Build timing scripts if (GTSAM_BUILD_TIMING) + # Subdirectory target for timing - does not actually execute the scripts add_custom_target(timing.tests) - file(GLOB timing_srcs "time*.cpp") - list(REMOVE_ITEM timing_srcs ${tests_exclude}) - foreach(time_src ${timing_srcs}) - get_filename_component(time_base ${time_src} NAME_WE) - set( time_bin ${time_base} ) - message(STATUS "Adding Timing Benchmark ${time_bin}") - add_executable(${time_bin} ${time_src}) - add_dependencies(timing.tests ${time_bin}) - add_dependencies(timing ${time_bin}) - target_link_libraries(${time_bin} ${convenience_libs} CppUnitLite ${Boost_LIBRARIES}) - add_custom_target(${time_bin}.run ${EXECUTABLE_OUTPUT_PATH}${time_bin} ${ARGN}) - endforeach(time_src) + set(is_test FALSE) + + # Build grouped benchmarks + gtsam_add_grouped_scripts("tests" # Use subdirectory as group label + "time*.cpp" timing "Timing Benchmark" # Standard for all timing scripts + "${tests_local_libs}" "gtsam-static" "${tests_exclude}" # Pass in linking and exclusion lists + ${is_test}) endif (GTSAM_BUILD_TIMING) diff --git a/wrap/CMakeLists.txt b/wrap/CMakeLists.txt index 21f39fdb5..4e045cf66 100644 --- a/wrap/CMakeLists.txt +++ b/wrap/CMakeLists.txt @@ -17,8 +17,9 @@ install(FILES matlab.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include/wrap) # Build tests if (GTSAM_BUILD_TESTS) - add_definitions(-DTOPSRCDIR="${CMAKE_SOURCE_DIR}") - gtsam_add_external_tests(wrap wrap_lib) + add_definitions(-DTOPSRCDIR="${CMAKE_SOURCE_DIR}") + set(wrap_local_libs wrap_lib) + gtsam_add_subdir_tests("wrap" "${wrap_local_libs}" "${wrap_local_libs}" "") endif(GTSAM_BUILD_TESTS) # Wrap codegen