Skip to content

Commit

Permalink
Fix running the tests with shared library on Windows.
Browse files Browse the repository at this point in the history
Without this fix, the test executable fails because it can not find
the dll of Catch2.
  • Loading branch information
dimztimz authored and horenmar committed Jul 25, 2022
1 parent 2b0fd85 commit 997a7d4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 997a7d4

Please sign in to comment.