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 2022-07-18 11:28:04 +02:00 committed by Martin Hořeňovský
parent 2b0fd854e2
commit 997a7d4165
1 changed files with 6 additions and 0 deletions

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)