mirror of
https://github.com/SFML/SFML.git
synced 2024-11-25 04:41:05 +08:00
4586db91a9
This removes the sfml- prefixed targets from the export set. The sfml- prefixed targets are still available within the build tree but not to downstream users thus making this an API breaking change when compared to the 2.x releases. To keep things consistent, usage of the sfml- targets were replaced with their namespaced counterparts. This has a number of benefits: 1. It's more idiomatic. Modern CMake libraries are expected to have namespaced targets. 2. Namespaced targets are less likely to collide with user-defined targets. No one will accidentally define a SFML:: target. 3. If a namespaced target is not found by CMake, configuration will immediately stop.
61 lines
2.0 KiB
CMake
61 lines
2.0 KiB
CMake
cmake_minimum_required(VERSION 3.14)
|
|
|
|
set(SRCROOT "${PROJECT_SOURCE_DIR}/test")
|
|
|
|
add_library(sfml-test-main STATIC "${SRCROOT}/DoctestMain.cpp")
|
|
target_include_directories(sfml-test-main PUBLIC "${PROJECT_SOURCE_DIR}/extlibs/headers" "${SRCROOT}/TestUtilities")
|
|
target_compile_features(sfml-test-main PRIVATE cxx_std_17)
|
|
|
|
# System is always built
|
|
SET(SYSTEM_SRC
|
|
"${SRCROOT}/System/FileInputStream.cpp"
|
|
"${SRCROOT}/System/Time.cpp"
|
|
"${SRCROOT}/System/Vector2.cpp"
|
|
"${SRCROOT}/System/Vector3.cpp"
|
|
"${SRCROOT}/TestUtilities/SystemUtil.hpp"
|
|
"${SRCROOT}/TestUtilities/SystemUtil.cpp"
|
|
)
|
|
sfml_add_test(test-sfml-system "${SYSTEM_SRC}" SFML::System)
|
|
target_link_libraries(test-sfml-system PRIVATE sfml-test-main)
|
|
|
|
if(SFML_BUILD_WINDOW)
|
|
SET(WINDOW_SRC
|
|
"${SRCROOT}/Window/VideoMode.cpp"
|
|
"${SRCROOT}/TestUtilities/WindowUtil.hpp"
|
|
"${SRCROOT}/TestUtilities/WindowUtil.cpp"
|
|
)
|
|
sfml_add_test(test-sfml-window "${WINDOW_SRC}" SFML::Window)
|
|
target_link_libraries(test-sfml-window PRIVATE sfml-test-main)
|
|
endif()
|
|
|
|
if(SFML_BUILD_GRAPHICS)
|
|
SET(GRAPHICS_SRC
|
|
"${SRCROOT}/Graphics/Color.cpp"
|
|
"${SRCROOT}/Graphics/Rect.cpp"
|
|
"${SRCROOT}/Graphics/Transform.cpp"
|
|
"${SRCROOT}/Graphics/Vertex.cpp"
|
|
"${SRCROOT}/TestUtilities/GraphicsUtil.hpp"
|
|
"${SRCROOT}/TestUtilities/GraphicsUtil.cpp"
|
|
)
|
|
sfml_add_test(test-sfml-graphics "${GRAPHICS_SRC}" SFML::Graphics)
|
|
target_link_libraries(test-sfml-graphics PRIVATE sfml-test-main)
|
|
endif()
|
|
|
|
if(SFML_BUILD_NETWORK)
|
|
SET(NETWORK_SRC
|
|
"${SRCROOT}/Network/Packet.cpp"
|
|
)
|
|
sfml_add_test(test-sfml-network "${NETWORK_SRC}" SFML::Network)
|
|
target_link_libraries(test-sfml-network PRIVATE sfml-test-main)
|
|
endif()
|
|
|
|
# Automatically run the tests at the end of the build
|
|
add_custom_target(runtests ALL
|
|
DEPENDS test-sfml-system test-sfml-window test-sfml-graphics test-sfml-network
|
|
)
|
|
|
|
add_custom_command(TARGET runtests
|
|
COMMENT "Run tests"
|
|
POST_BUILD COMMAND ctest ARGS --output-on-failure
|
|
)
|