From 997a7d4165b3939347f1a95f9311a3e3c066ee0b Mon Sep 17 00:00:00 2001 From: Dimitrij Mijoski Date: Mon, 18 Jul 2022 11:28:04 +0200 Subject: [PATCH] Fix running the tests with shared library on Windows. Without this fix, the test executable fails because it can not find the dll of Catch2. --- tests/CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 0a605e12..7f5af994 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -146,6 +146,12 @@ include(CTest) add_executable(SelfTest ${TEST_SOURCES}) target_link_libraries(SelfTest PRIVATE Catch2WithMain) +if (BUILD_SHARED_LIBS AND WIN32) + add_custom_command(TARGET SelfTest PRE_LINK + COMMAND ${CMAKE_COMMAND} -E copy_if_different $ + $ $ + ) +endif() if (CATCH_ENABLE_COVERAGE) set(ENABLE_COVERAGE ON CACHE BOOL "Enable coverage build." FORCE)