2021-12-09 19:08:55 -07:00
|
|
|
cmake_minimum_required(VERSION 3.14)
|
|
|
|
|
2021-12-23 11:28:14 -06:00
|
|
|
set(SRCROOT "${PROJECT_SOURCE_DIR}/test")
|
2015-04-28 21:54:03 +02:00
|
|
|
|
2021-12-24 14:31:27 +01:00
|
|
|
add_library(sfml-test-main STATIC "${SRCROOT}/DoctestMain.cpp")
|
|
|
|
target_include_directories(sfml-test-main PUBLIC "${PROJECT_SOURCE_DIR}/extlibs/headers" "${SRCROOT}/TestUtilities")
|
2021-12-17 21:39:38 -07:00
|
|
|
target_compile_features(sfml-test-main PRIVATE cxx_std_17)
|
2018-08-19 01:30:53 +02:00
|
|
|
|
|
|
|
# System is always built
|
|
|
|
SET(SYSTEM_SRC
|
2021-12-23 17:10:21 -06:00
|
|
|
"${SRCROOT}/System/Clock.cpp"
|
2021-12-24 17:16:06 +01:00
|
|
|
"${SRCROOT}/System/FileInputStream.cpp"
|
2021-12-18 08:32:40 -07:00
|
|
|
"${SRCROOT}/System/Time.cpp"
|
2018-08-20 08:51:42 +01:00
|
|
|
"${SRCROOT}/System/Vector2.cpp"
|
|
|
|
"${SRCROOT}/System/Vector3.cpp"
|
|
|
|
"${SRCROOT}/TestUtilities/SystemUtil.hpp"
|
|
|
|
"${SRCROOT}/TestUtilities/SystemUtil.cpp"
|
2015-04-28 21:54:03 +02:00
|
|
|
)
|
2021-12-28 22:28:50 -07:00
|
|
|
sfml_add_test(test-sfml-system "${SYSTEM_SRC}" SFML::System)
|
2021-12-17 21:39:38 -07:00
|
|
|
target_link_libraries(test-sfml-system PRIVATE sfml-test-main)
|
2015-04-28 21:54:03 +02:00
|
|
|
|
2018-08-19 01:30:53 +02:00
|
|
|
if(SFML_BUILD_WINDOW)
|
|
|
|
SET(WINDOW_SRC
|
2022-01-11 20:17:15 -07:00
|
|
|
"${SRCROOT}/Window/ContextSettings.cpp"
|
2021-12-23 16:21:51 -06:00
|
|
|
"${SRCROOT}/Window/VideoMode.cpp"
|
2018-08-20 08:51:42 +01:00
|
|
|
"${SRCROOT}/TestUtilities/WindowUtil.hpp"
|
|
|
|
"${SRCROOT}/TestUtilities/WindowUtil.cpp"
|
2018-08-19 01:30:53 +02:00
|
|
|
)
|
2021-12-28 22:28:50 -07:00
|
|
|
sfml_add_test(test-sfml-window "${WINDOW_SRC}" SFML::Window)
|
2021-12-17 21:39:38 -07:00
|
|
|
target_link_libraries(test-sfml-window PRIVATE sfml-test-main)
|
2018-08-19 01:30:53 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(SFML_BUILD_GRAPHICS)
|
|
|
|
SET(GRAPHICS_SRC
|
2022-01-11 14:40:51 -07:00
|
|
|
"${SRCROOT}/Graphics/BlendMode.cpp"
|
2021-12-24 18:04:04 +01:00
|
|
|
"${SRCROOT}/Graphics/Color.cpp"
|
2018-08-20 08:51:42 +01:00
|
|
|
"${SRCROOT}/Graphics/Rect.cpp"
|
2021-12-23 18:18:33 -06:00
|
|
|
"${SRCROOT}/Graphics/Transform.cpp"
|
2022-01-02 20:59:15 -07:00
|
|
|
"${SRCROOT}/Graphics/Vertex.cpp"
|
2018-08-20 08:51:42 +01:00
|
|
|
"${SRCROOT}/TestUtilities/GraphicsUtil.hpp"
|
|
|
|
"${SRCROOT}/TestUtilities/GraphicsUtil.cpp"
|
2018-08-19 01:30:53 +02:00
|
|
|
)
|
2021-12-28 22:28:50 -07:00
|
|
|
sfml_add_test(test-sfml-graphics "${GRAPHICS_SRC}" SFML::Graphics)
|
2021-12-17 21:39:38 -07:00
|
|
|
target_link_libraries(test-sfml-graphics PRIVATE sfml-test-main)
|
2018-08-19 01:30:53 +02:00
|
|
|
endif()
|
|
|
|
|
2021-12-05 23:27:48 +01:00
|
|
|
if(SFML_BUILD_NETWORK)
|
|
|
|
SET(NETWORK_SRC
|
|
|
|
"${SRCROOT}/Network/Packet.cpp"
|
|
|
|
)
|
2021-12-28 22:28:50 -07:00
|
|
|
sfml_add_test(test-sfml-network "${NETWORK_SRC}" SFML::Network)
|
2021-12-17 21:39:38 -07:00
|
|
|
target_link_libraries(test-sfml-network PRIVATE sfml-test-main)
|
2021-12-05 23:27:48 +01:00
|
|
|
endif()
|
|
|
|
|
2018-08-19 19:04:11 +01:00
|
|
|
# Automatically run the tests at the end of the build
|
2018-08-20 23:49:56 +02:00
|
|
|
add_custom_target(runtests ALL
|
2021-12-05 23:27:48 +01:00
|
|
|
DEPENDS test-sfml-system test-sfml-window test-sfml-graphics test-sfml-network
|
2018-08-19 01:30:53 +02:00
|
|
|
)
|
2018-11-29 18:38:27 +00:00
|
|
|
|
2018-08-19 19:04:11 +01:00
|
|
|
add_custom_command(TARGET runtests
|
|
|
|
COMMENT "Run tests"
|
|
|
|
POST_BUILD COMMAND ctest ARGS --output-on-failure
|
2019-02-11 22:32:04 +01:00
|
|
|
)
|