find_package(Boost REQUIRED COMPONENTS unit_test_framework) set(TEST_LOGGING unit_scope CACHE STRING "test log level") function(create_test name source) set(TEST_MAIN_FILE ${CMAKE_CURRENT_BINARY_DIR}/test/test_main.cpp) file(WRITE ${TEST_MAIN_FILE} "#define BOOST_TEST_MODULE ${name}\n#include ") add_library(${name}-test-main ${TEST_MAIN_FILE}) target_link_libraries(${name}-test-main PUBLIC Boost::unit_test_framework) add_executable(${name} ${source}) target_link_libraries(${name} PUBLIC setgraph PRIVATE ${name}-test-main) add_test(NAME ${name} COMMAND $ -l ${TEST_LOGGING}) target_compile_definitions(${name} PUBLIC BOOST_TEST_DYN_LINK) target_compile_options(${name} PRIVATE $<$,$,$>: -Wall -Wextra> $<$: /W4>) #target_precompile_headers(${name} PRIVATE boost_test_pch.h) endfunction() create_test(TestGraph testGraph.cpp) create_test(TestBoostIntegration testBoostIntegration.cpp) target_link_libraries(TestBoostIntegration PUBLIC setgraph-boost)