From 9b3a4e28c5ab0c4f78c21b0b7178cced7f5b6e2c Mon Sep 17 00:00:00 2001 From: Gabi Melman Date: Sun, 1 Oct 2023 17:42:44 +0300 Subject: [PATCH] Copy spdlog dll to the executable folder for example, tests and bench --- bench/CMakeLists.txt | 6 ++++++ example/CMakeLists.txt | 14 ++++++++++---- tests/CMakeLists.txt | 7 +++++++ 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/bench/CMakeLists.txt b/bench/CMakeLists.txt index 3806b24b..9ef82cb1 100644 --- a/bench/CMakeLists.txt +++ b/bench/CMakeLists.txt @@ -35,3 +35,9 @@ target_link_libraries(latency PRIVATE benchmark::benchmark spdlog::spdlog) add_executable(formatter-bench formatter-bench.cpp) target_link_libraries(formatter-bench PRIVATE benchmark::benchmark spdlog::spdlog) + + +# copy dll to the executable folder for msvc +if(MSVC AND (SPDLOG_BUILD_SHARED OR BUILD_SHARED_LIBS)) + add_custom_command(TARGET bench POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $) +endif() diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index 8aca0a39..e83311af 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -1,15 +1,21 @@ # Copyright(c) 2019 spdlog authors Distributed under the MIT License (http://opensource.org/licenses/MIT) cmake_minimum_required(VERSION 3.11) -project(spdlog_examples CXX) +project(spdlog_example CXX) if(NOT TARGET spdlog) # Stand-alone build find_package(spdlog REQUIRED) endif() -# --------------------------------------------------------------------------------------- -# Example of using pre-compiled library -# --------------------------------------------------------------------------------------- + add_executable(example example.cpp) target_link_libraries(example PRIVATE spdlog::spdlog $<$:ws2_32>) + + +# copy dll to the executable folder for msvc +if(MSVC AND (SPDLOG_BUILD_SHARED OR BUILD_SHARED_LIBS)) + add_custom_command(TARGET example POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different + $ $) +endif() + diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 22971259..780aedf1 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -84,4 +84,11 @@ endfunction() if(SPDLOG_BUILD_TESTS OR SPDLOG_BUILD_ALL) spdlog_prepare_test(spdlog-utests spdlog::spdlog) + + # copy dll to the executable folder for msvc + if(MSVC AND (SPDLOG_BUILD_SHARED OR BUILD_SHARED_LIBS)) + add_custom_command(TARGET spdlog-utests POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different + $ $) + endif() + endif()