Skip to content

Commit

Permalink
catch2 - 2
Browse files Browse the repository at this point in the history
  • Loading branch information
mhekkel committed Jan 28, 2025
1 parent 0fc1680 commit 12bc698
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
1 change: 0 additions & 1 deletion .github/workflows/cmake-multi-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ jobs:
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-DFETCH_CATCH2=ON
-S ${{ github.workspace }}
- name: Build
Expand Down
22 changes: 9 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,22 +104,18 @@ if(BUILD_TESTING)
FetchContent_MakeAvailable(Catch2)
endif()

if(TARGET Catch2::Catch2WithMain)
file(GLOB UNIT_TEST_RSRC LIST_DIRECTORIES true ${PROJECT_SOURCE_DIR}/rsrc/*)
file(GLOB UNIT_TEST_RSRC LIST_DIRECTORIES true ${PROJECT_SOURCE_DIR}/rsrc/*)

add_custom_command(OUTPUT mrc-unit-test-rsrc.obj
COMMAND $<TARGET_FILE:mrc-bootstrap> -o mrc-unit-test-rsrc.obj ${UNIT_TEST_RSRC} ${COFF_SPEC}
DEPENDS ${UNIT_TEST_RSRC} mrc-bootstrap
)

add_executable(mrc-unit-test ${PROJECT_SOURCE_DIR}/src/mrc-unit-test.cpp ${CMAKE_BINARY_DIR}/mrc-unit-test-rsrc.obj)
add_custom_command(OUTPUT mrc-unit-test-rsrc.obj
COMMAND $<TARGET_FILE:mrc-bootstrap> -o mrc-unit-test-rsrc.obj ${UNIT_TEST_RSRC} ${COFF_SPEC}
DEPENDS ${UNIT_TEST_RSRC} mrc-bootstrap
)

target_link_libraries(mrc-unit-test Catch2::Catch2WithMain)
add_executable(mrc-unit-test ${PROJECT_SOURCE_DIR}/src/mrc-unit-test.cpp ${CMAKE_BINARY_DIR}/mrc-unit-test-rsrc.obj)

add_test(NAME unit-test COMMAND $<TARGET_FILE:mrc-unit-test> WORKING_DIRECTORY .)
else()
message(WARNING "No Catch2::Catch2WithMain target, something is wrong")
endif()
target_link_libraries(mrc-unit-test Catch2::Catch2WithMain)

add_test(NAME unit-test COMMAND $<TARGET_FILE:mrc-unit-test> WORKING_DIRECTORY .)
endif()

install(TARGETS mrc)
Expand Down

0 comments on commit 12bc698

Please sign in to comment.