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.
This commit is contained in:
Dimitrij Mijoski authored and Martin Hořeňovský committed 2022-07-25 21:07:49 +02:00
1 parent 2b0fd854e2
commit 997a7d4165
1 file changed
+6
+6
View File
@@ -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)