Copy spdlog dll to the executable folder for example, tests and bench

This commit is contained in:
Gabi Melman 2023-10-01 17:42:44 +03:00
parent cc343cd168
commit 9b3a4e28c5
3 changed files with 23 additions and 4 deletions

View File

@ -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 $<TARGET_FILE:spdlog> $<TARGET_FILE_DIR:bench>)
endif()

View File

@ -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 $<$<BOOL:${MINGW}>: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
$<TARGET_FILE:spdlog> $<TARGET_FILE_DIR:example>)
endif()

View File

@ -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
$<TARGET_FILE:spdlog> $<TARGET_FILE_DIR:spdlog-utests>)
endif()
endif()