From 9ca89ad6f81f89093c502594f4f07505908c89f0 Mon Sep 17 00:00:00 2001 From: Mario Emmenlauer Date: Fri, 10 Jan 2020 17:57:45 +0100 Subject: [PATCH] Ensure boost tests are linked statically or dynamically, depending on build (#23) --- tests/CMakeLists.txt | 6 ++++-- tests/unit_tests.cpp | 1 - 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 7bbf972..00fb9fb 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -15,9 +15,11 @@ if (Boost_FOUND) ut_ordered.cpp ut_keyed.cpp ) - include_directories(${Boost_INCLUDE_DIR}) target_compile_definitions(unit_tests PRIVATE BOOST_ALL_NO_LIB=1) - target_link_libraries(unit_tests ${Boost_LIBRARIES}) + if (NOT Boost_USE_STATIC_LIBS) + target_compile_definitions(unit_tests PRIVATE BOOST_TEST_DYN_LINK=1) + endif () + target_link_libraries(unit_tests Boost::unit_test_framework) add_test(NAME unit_tests COMMAND unit_tests) add_custom_target(test COMMAND unit_tests DEPENDS unit_tests) diff --git a/tests/unit_tests.cpp b/tests/unit_tests.cpp index 8ba0386..8d9856e 100644 --- a/tests/unit_tests.cpp +++ b/tests/unit_tests.cpp @@ -1,3 +1,2 @@ -#define BOOST_TEST_DYN_LINK #define BOOST_TEST_MODULE st_tree #include