Skip to content

Commit 997a7d4

Browse files
dimztimzhorenmar
authored andcommitted
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.
1 parent 2b0fd85 commit 997a7d4

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

tests/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,12 @@ include(CTest)
146146

147147
add_executable(SelfTest ${TEST_SOURCES})
148148
target_link_libraries(SelfTest PRIVATE Catch2WithMain)
149+
if (BUILD_SHARED_LIBS AND WIN32)
150+
add_custom_command(TARGET SelfTest PRE_LINK
151+
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:Catch2>
152+
$<TARGET_FILE:Catch2WithMain> $<TARGET_FILE_DIR:SelfTest>
153+
)
154+
endif()
149155

150156
if (CATCH_ENABLE_COVERAGE)
151157
set(ENABLE_COVERAGE ON CACHE BOOL "Enable coverage build." FORCE)

0 commit comments

Comments
 (0)