Require all modules are built before building tests

This commit is contained in:
Chris Thrasher 2022-03-24 11:49:00 -06:00 committed by Lukas Dürrenberger
parent bc7ec1277a
commit f3d98a9ebf
2 changed files with 26 additions and 33 deletions

View File

@ -282,9 +282,11 @@ endif()
if(SFML_BUILD_TEST_SUITE)
if (SFML_OS_IOS)
message( WARNING "Unit testing not supported on iOS")
else()
elseif(SFML_BUILD_WINDOW AND SFML_BUILD_GRAPHICS AND SFML_BUILD_NETWORK AND SFML_BUILD_AUDIO)
enable_testing()
add_subdirectory(test)
else()
message(WARNING "Cannot build unit testing unless all modules are enabled")
endif()
endif()

View File

@ -11,7 +11,6 @@ target_include_directories(sfml-test-main SYSTEM PUBLIC "${PROJECT_SOURCE_DIR}/e
target_include_directories(sfml-test-main PUBLIC TestUtilities)
target_link_libraries(sfml-test-main PUBLIC SFML::System)
# System is always built
SET(SYSTEM_SRC
System/Angle.cpp
System/Clock.cpp
@ -22,15 +21,12 @@ SET(SYSTEM_SRC
)
sfml_add_test(test-sfml-system "${SYSTEM_SRC}" SFML::System)
if(SFML_BUILD_WINDOW)
SET(WINDOW_SRC
Window/ContextSettings.cpp
Window/VideoMode.cpp
)
sfml_add_test(test-sfml-window "${WINDOW_SRC}" SFML::Window)
endif()
if(SFML_BUILD_GRAPHICS)
SET(GRAPHICS_SRC
Graphics/BlendMode.cpp
Graphics/Color.cpp
@ -41,21 +37,16 @@ if(SFML_BUILD_GRAPHICS)
Graphics/VertexArray.cpp
)
sfml_add_test(test-sfml-graphics "${GRAPHICS_SRC}" SFML::Graphics)
endif()
if(SFML_BUILD_NETWORK)
SET(NETWORK_SRC
Network/Packet.cpp
)
sfml_add_test(test-sfml-network "${NETWORK_SRC}" SFML::Network)
endif()
if(SFML_BUILD_AUDIO)
SET(AUDIO_SRC
Audio/Dummy.cpp # TODO: Remove when there are real tests
)
sfml_add_test(test-sfml-audio "${AUDIO_SRC}" SFML::Audio)
endif()
# Automatically run the tests at the end of the build
add_custom_target(runtests ALL