Skip to content

Commit

Permalink
[ci] Force compiling tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jcelerier committed Jul 18, 2023
1 parent 574985b commit 64639f5
Showing 1 changed file with 28 additions and 31 deletions.
59 changes: 28 additions & 31 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -334,35 +334,32 @@ if(LIBREMIDI_TESTS)

FetchContent_MakeAvailable(Catch2)
endif()
if(TARGET Catch2::Catch2WithMain AND Catch2_FOUND)
message(STATUS "libremidi: compiling tests")
target_compile_features(libremidi ${_public} cxx_std_20)

add_executable(midiin_test tests/unit/midi_in.cpp)
target_link_libraries(midiin_test PRIVATE libremidi Catch2::Catch2WithMain)

add_executable(midiout_test tests/unit/midi_out.cpp)
target_link_libraries(midiout_test PRIVATE libremidi Catch2::Catch2WithMain)

add_executable(midifile_read_test tests/unit/midifile_read.cpp)
target_link_libraries(midifile_read_test PRIVATE libremidi Catch2::Catch2WithMain)
target_compile_definitions(midifile_read_test PRIVATE "LIBREMIDI_TEST_CORPUS=\"${CMAKE_CURRENT_SOURCE_DIR}/tests/corpus\"")

add_executable(midifile_write_test tests/unit/midifile_write.cpp)
target_link_libraries(midifile_write_test PRIVATE libremidi Catch2::Catch2WithMain)
target_compile_definitions(midifile_write_test PRIVATE "LIBREMIDI_TEST_CORPUS=\"${CMAKE_CURRENT_SOURCE_DIR}/tests/corpus\"")

add_executable(midifile_write_tracks_test tests/integration/midifile_write_tracks.cpp)
target_link_libraries(midifile_write_tracks_test PRIVATE libremidi Catch2::Catch2WithMain)

include(CTest)
include(Catch)
catch_discover_tests(midiin_test)
catch_discover_tests(midiout_test)
catch_discover_tests(midifile_read_test)
catch_discover_tests(midifile_write_test)
catch_discover_tests(midifile_write_tracks_test)
else()
message(STATUS "libremidi: not compiling tests")
endif()

message(STATUS "libremidi: compiling tests")
target_compile_features(libremidi ${_public} cxx_std_20)

add_executable(midiin_test tests/unit/midi_in.cpp)
target_link_libraries(midiin_test PRIVATE libremidi Catch2::Catch2WithMain)

add_executable(midiout_test tests/unit/midi_out.cpp)
target_link_libraries(midiout_test PRIVATE libremidi Catch2::Catch2WithMain)

add_executable(midifile_read_test tests/unit/midifile_read.cpp)
target_link_libraries(midifile_read_test PRIVATE libremidi Catch2::Catch2WithMain)
target_compile_definitions(midifile_read_test PRIVATE "LIBREMIDI_TEST_CORPUS=\"${CMAKE_CURRENT_SOURCE_DIR}/tests/corpus\"")

add_executable(midifile_write_test tests/unit/midifile_write.cpp)
target_link_libraries(midifile_write_test PRIVATE libremidi Catch2::Catch2WithMain)
target_compile_definitions(midifile_write_test PRIVATE "LIBREMIDI_TEST_CORPUS=\"${CMAKE_CURRENT_SOURCE_DIR}/tests/corpus\"")

add_executable(midifile_write_tracks_test tests/integration/midifile_write_tracks.cpp)
target_link_libraries(midifile_write_tracks_test PRIVATE libremidi Catch2::Catch2WithMain)

include(CTest)
include(Catch)
catch_discover_tests(midiin_test)
catch_discover_tests(midiout_test)
catch_discover_tests(midifile_read_test)
catch_discover_tests(midifile_write_test)
catch_discover_tests(midifile_write_tracks_test)
endif()

0 comments on commit 64639f5

Please sign in to comment.