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,40 +21,32 @@ 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()
SET(WINDOW_SRC
Window/ContextSettings.cpp
Window/VideoMode.cpp
)
sfml_add_test(test-sfml-window "${WINDOW_SRC}" SFML::Window)
if(SFML_BUILD_GRAPHICS)
SET(GRAPHICS_SRC
Graphics/BlendMode.cpp
Graphics/Color.cpp
Graphics/Rect.cpp
Graphics/Transform.cpp
Graphics/Transformable.cpp
Graphics/Vertex.cpp
Graphics/VertexArray.cpp
)
sfml_add_test(test-sfml-graphics "${GRAPHICS_SRC}" SFML::Graphics)
endif()
SET(GRAPHICS_SRC
Graphics/BlendMode.cpp
Graphics/Color.cpp
Graphics/Rect.cpp
Graphics/Transform.cpp
Graphics/Transformable.cpp
Graphics/Vertex.cpp
Graphics/VertexArray.cpp
)
sfml_add_test(test-sfml-graphics "${GRAPHICS_SRC}" SFML::Graphics)
if(SFML_BUILD_NETWORK)
SET(NETWORK_SRC
Network/Packet.cpp
)
sfml_add_test(test-sfml-network "${NETWORK_SRC}" SFML::Network)
endif()
SET(NETWORK_SRC
Network/Packet.cpp
)
sfml_add_test(test-sfml-network "${NETWORK_SRC}" SFML::Network)
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()
SET(AUDIO_SRC
Audio/Dummy.cpp # TODO: Remove when there are real tests
)
sfml_add_test(test-sfml-audio "${AUDIO_SRC}" SFML::Audio)
# Automatically run the tests at the end of the build
add_custom_target(runtests ALL