Progmasoft Git

catch3

Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.

Clonegit clone https://git.progmasoft.com/catch3

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.
Commit
997a7d4165b3939347f1a95f9311a3e3c066ee0b
Author
Dimitrij Mijoski ·
Committer
Martin Hořeňovský
Parents
2b0fd854e2ec

Files · Download .tar.gz

Changes

 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 $<TARGET_FILE:Catch2>
+        $<TARGET_FILE:Catch2WithMain> $<TARGET_FILE_DIR:SelfTest>
+    )
+endif()
 
 if (CATCH_ENABLE_COVERAGE)
     set(ENABLE_COVERAGE ON CACHE BOOL "Enable coverage build." FORCE)