Fixed bugs in last commit and made GTSAM_SINGLE_TEST_EXE default on Xcode too
parent
3e3f31c4d1
commit
e7018e8c51
|
@ -12,11 +12,12 @@ endif()
|
||||||
add_custom_target(timing)
|
add_custom_target(timing)
|
||||||
|
|
||||||
# Add option for combining unit tests
|
# Add option for combining unit tests
|
||||||
if(MSVC)
|
if(MSVC OR XCODE_VERSION)
|
||||||
option(GTSAM_SINGLE_TEST_EXE "Combine unit tests into single executable (faster compile)" ON)
|
option(GTSAM_SINGLE_TEST_EXE "Combine unit tests into single executable (faster compile)" ON)
|
||||||
else()
|
else()
|
||||||
option(GTSAM_SINGLE_TEST_EXE "Combine unit tests into single executable (faster compile)" OFF)
|
option(GTSAM_SINGLE_TEST_EXE "Combine unit tests into single executable (faster compile)" OFF)
|
||||||
endif()
|
endif()
|
||||||
|
mark_as_advanced(GTSAM_SINGLE_TEST_EXE)
|
||||||
|
|
||||||
# Macro for adding glob(s) of tests relative to the current directory. Automatically
|
# Macro for adding glob(s) of tests relative to the current directory. Automatically
|
||||||
# links the tests with CppUnitLite. Separate multiple globPatterns, linkLibraries,
|
# links the tests with CppUnitLite. Separate multiple globPatterns, linkLibraries,
|
||||||
|
@ -33,13 +34,13 @@ macro(gtsamAddTestsGlob groupName globPatterns excludedFiles linkLibraries)
|
||||||
set(script_files_relative "")
|
set(script_files_relative "")
|
||||||
foreach(one_pattern IN ITEMS ${globPatterns})
|
foreach(one_pattern IN ITEMS ${globPatterns})
|
||||||
message(STATUS "Filling test group ${groupName}")
|
message(STATUS "Filling test group ${groupName}")
|
||||||
file(GLOB RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} one_script_files "${one_pattern}")
|
file(GLOB one_script_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${one_pattern}")
|
||||||
list(APPEND script_files_relative "${one_script_files}")
|
list(APPEND script_files_relative ${one_script_files})
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
# Remove excluded scripts from the list
|
# Remove excluded scripts from the list
|
||||||
if(excludedFiles)
|
if(NOT "${excludedFiles}" STREQUAL "")
|
||||||
list(REMOVE_ITEM script_files_relative excludedFiles)
|
list(REMOVE_ITEM script_files_relative ${excludedFiles})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Get absolute paths
|
# Get absolute paths
|
||||||
|
@ -65,12 +66,13 @@ macro(gtsamAddTestsGlob groupName globPatterns excludedFiles linkLibraries)
|
||||||
source_group("" FILES ${script_srcs} ${script_headers})
|
source_group("" FILES ${script_srcs} ${script_headers})
|
||||||
|
|
||||||
if(NOT GTSAM_SINGLE_TEST_EXE)
|
if(NOT GTSAM_SINGLE_TEST_EXE)
|
||||||
|
# Default for Makefiles - each test in its own executable
|
||||||
foreach(script_src IN ITEMS ${script_srcs})
|
foreach(script_src IN ITEMS ${script_srcs})
|
||||||
# Get test base name
|
# Get test base name
|
||||||
get_filename_component(script_name ${script_src} NAME_WE)
|
get_filename_component(script_name ${script_src} NAME_WE)
|
||||||
|
|
||||||
# Add executable
|
# Add executable
|
||||||
add_executable(script_name ${script_src} ${script_headers})
|
add_executable(${script_name} ${script_src} ${script_headers})
|
||||||
target_link_libraries(${script_name} CppUnitLite ${linkLibraries})
|
target_link_libraries(${script_name} CppUnitLite ${linkLibraries})
|
||||||
|
|
||||||
# Add target dependencies
|
# Add target dependencies
|
||||||
|
@ -91,7 +93,7 @@ macro(gtsamAddTestsGlob groupName globPatterns excludedFiles linkLibraries)
|
||||||
set_property(TARGET ${script_name} PROPERTY FOLDER "Unit tests/${groupName}")
|
set_property(TARGET ${script_name} PROPERTY FOLDER "Unit tests/${groupName}")
|
||||||
endforeach()
|
endforeach()
|
||||||
else()
|
else()
|
||||||
# Create single unit test exe from all test scripts
|
# Default on MSVC and XCode - combine test group into a single exectuable
|
||||||
set(target_name check_${groupName}_program)
|
set(target_name check_${groupName}_program)
|
||||||
|
|
||||||
# Add executable
|
# Add executable
|
||||||
|
|
Loading…
Reference in New Issue