From e351dadef6ec5a398efc119b140c7c83b5a4324e Mon Sep 17 00:00:00 2001 From: Gabor Janak Date: Mon, 13 Aug 2018 14:25:40 +0200 Subject: [PATCH] Improve CmakeBuildsystem to define spdlog library depednecy on Target only one time. on Mingw use Boost thread package. --- CMakeLists.txt | 8 ++++++++ bench/CMakeLists.txt | 7 +++---- example/CMakeLists.txt | 4 ++-- tests/CMakeLists.txt | 2 -- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b9319d17..512489c1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,6 +57,14 @@ target_include_directories( "$" "$" ) +#Setting thread dependency to Target spdlog, neded for examples,bench,tests +IF ( MINGW ) +FIND_PACKAGE( Boost 1.62 REQUIRED COMPONENTS thread) +target_link_libraries(spdlog INTERFACE Boost::thread ) +else() +find_package(Threads REQUIRED) +target_link_libraries(spdlog INTERFACE Threads::Threads ) +endif() set(HEADER_BASE "${CMAKE_CURRENT_SOURCE_DIR}/include") diff --git a/bench/CMakeLists.txt b/bench/CMakeLists.txt index 0eb25eb2..bca988b1 100644 --- a/bench/CMakeLists.txt +++ b/bench/CMakeLists.txt @@ -33,16 +33,15 @@ if(NOT TARGET spdlog) find_package(spdlog CONFIG REQUIRED) endif() -find_package(Threads REQUIRED) add_executable(bench bench.cpp) -target_link_libraries(bench spdlog::spdlog Threads::Threads -flto) +target_link_libraries(bench spdlog::spdlog) add_executable(async_bench async_bench.cpp) -target_link_libraries(async_bench spdlog::spdlog Threads::Threads) +target_link_libraries(async_bench spdlog::spdlog) add_executable(latency latency.cpp) -target_link_libraries(latency spdlog::spdlog Threads::Threads) +target_link_libraries(latency spdlog::spdlog) diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index 69eb374e..fca0e9b7 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -32,10 +32,10 @@ endif() find_package(Threads REQUIRED) add_executable(example example.cpp) -target_link_libraries(example spdlog::spdlog Threads::Threads) +target_link_libraries(example spdlog::spdlog) add_executable(multisink multisink.cpp) -target_link_libraries(multisink spdlog::spdlog Threads::Threads) +target_link_libraries(multisink spdlog::spdlog) enable_testing() file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/logs") diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 18af9770..967c2804 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,6 +1,5 @@ project(spdlog-utests CXX) enable_testing() -find_package(Threads REQUIRED) set(SPDLOG_UTESTS_SOURCES errors.cpp @@ -17,7 +16,6 @@ set(SPDLOG_UTESTS_SOURCES main.cpp) add_executable(${PROJECT_NAME} ${SPDLOG_UTESTS_SOURCES}) -target_link_libraries(${PROJECT_NAME} PRIVATE Threads::Threads) target_link_libraries(${PROJECT_NAME} PRIVATE spdlog::spdlog) add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME})