Warning, /acts/Tests/UnitTests/CMakeLists.txt is written in an unsupported language. File is not indexed.
0001 # add a unittest executable w/ default dependencies and register it.
0002
0003 # the common libraries which are linked to every unittest can be
0004 # extended by setting the `unittest_extra_libraries` variables before
0005 # calling the macro.
0006
0007 # any arguments after the source file are passed to the test executable on the
0008 # ctest command line, e.g. paths that the test needs but cannot know itself.
0009 # The test reads them from boost::unit_test::framework::master_test_suite().
0010
0011 add_custom_target(unit_tests)
0012
0013 macro(add_unittest _name _source)
0014 # automatically prefix the target name
0015 set(_target "ActsUnitTest${_name}")
0016 add_executable(${_target} ${_source})
0017 # define required BOOST_TEST_... macros here to ensure consistent names
0018 target_compile_definitions(${_target} PRIVATE "-DBOOST_TEST_DYN_LINK")
0019 set_source_files_properties(
0020 ${_source}
0021 PROPERTIES COMPILE_DEFINITIONS "BOOST_TEST_MODULE=${_target}"
0022 )
0023 target_include_directories(${_target} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
0024 target_link_libraries(
0025 ${_target}
0026 PRIVATE
0027 Acts::TestsCommonHelpers
0028 Boost::unit_test_framework
0029 ${unittest_extra_libraries}
0030 )
0031 if(ACTS_TESTS_HAS_WNO_C2Y_EXTENSIONS)
0032 target_compile_options(${_target} PRIVATE -Wno-c2y-extensions)
0033 endif()
0034 # register as unittest executable. Extra arguments go behind the --
0035 # separator, where Boost.Test wants everything that is not one of its own
0036 # options, and arrive as master_test_suite().argv
0037 if(${ARGC} GREATER 2)
0038 add_test(NAME ${_name} COMMAND ${_target} -- ${ARGN})
0039 else()
0040 add_test(NAME ${_name} COMMAND ${_target})
0041 endif()
0042 add_dependencies(unit_tests ${_target})
0043 endmacro()
0044
0045 add_subdirectory_if(Core ACTS_BUILD_CORE_UNITTESTS)
0046 add_subdirectory_if(
0047 Examples
0048 ACTS_BUILD_EXAMPLES
0049 AND
0050 ACTS_BUILD_EXAMPLES_UNITTESTS
0051 )
0052 add_subdirectory_if(Benchmarks ACTS_BUILD_BENCHMARKS)
0053 add_subdirectory_if(Fatras ACTS_BUILD_FATRAS)
0054 add_subdirectory(Plugins)
0055 add_subdirectory_if(Alignment ACTS_BUILD_ALIGNMENT)