From 7c9bae3f6bb8ca4587eb3f4aa2cd293c58f1ab91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20D=C3=BCrrenberger?= Date: Wed, 13 Nov 2024 15:17:06 +0100 Subject: [PATCH] Add test to verify different consumptions of SFML --- test/integrate/FetchContent/CMakeLists.txt | 14 ++++++++++ test/integrate/FindPackage/CMakeLists.txt | 11 ++++++++ test/integrate/SubDirectory/CMakeLists.txt | 9 +++++++ test/integrate/main.cpp | 30 ++++++++++++++++++++++ 4 files changed, 64 insertions(+) create mode 100644 test/integrate/FetchContent/CMakeLists.txt create mode 100644 test/integrate/FindPackage/CMakeLists.txt create mode 100644 test/integrate/SubDirectory/CMakeLists.txt create mode 100644 test/integrate/main.cpp diff --git a/test/integrate/FetchContent/CMakeLists.txt b/test/integrate/FetchContent/CMakeLists.txt new file mode 100644 index 000000000..399e0df5e --- /dev/null +++ b/test/integrate/FetchContent/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.24) + +project(FetchContent LANGUAGES CXX) + +include(FetchContent) +FetchContent_Declare(SFML + SOURCE_DIR ${CMAKE_SOURCE_DIR}/../../../ + EXCLUDE_FROM_ALL + SYSTEM) +FetchContent_MakeAvailable(SFML) + +add_executable(main ../main.cpp) +target_link_libraries(main PRIVATE SFML::Graphics SFML::Audio) +target_compile_features(main PRIVATE cxx_std_17) diff --git a/test/integrate/FindPackage/CMakeLists.txt b/test/integrate/FindPackage/CMakeLists.txt new file mode 100644 index 000000000..92bef283f --- /dev/null +++ b/test/integrate/FindPackage/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.24) + +project(FindPackage LANGUAGES CXX) + +set(SFML_STATIC_LIBRARIES ON) + +find_package(SFML 3 REQUIRED COMPONENTS Graphics Audio) + +add_executable(main ../main.cpp) +target_link_libraries(main PRIVATE SFML::Graphics SFML::Audio) +target_compile_features(main PRIVATE cxx_std_17) diff --git a/test/integrate/SubDirectory/CMakeLists.txt b/test/integrate/SubDirectory/CMakeLists.txt new file mode 100644 index 000000000..14d621a56 --- /dev/null +++ b/test/integrate/SubDirectory/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.24) + +project(SubDirectory LANGUAGES CXX) + +add_subdirectory(${CMAKE_SOURCE_DIR}/../../../ ${CMAKE_CURRENT_BINARY_DIR}/SFML EXCLUDE_FROM_ALL SYSTEM) + +add_executable(main ../main.cpp) +target_link_libraries(main PRIVATE SFML::Graphics SFML::Audio) +target_compile_features(main PRIVATE cxx_std_17) diff --git a/test/integrate/main.cpp b/test/integrate/main.cpp new file mode 100644 index 000000000..2fc277c93 --- /dev/null +++ b/test/integrate/main.cpp @@ -0,0 +1,30 @@ +#include +#include + +int main() +{ + sf::RenderWindow window(sf::VideoMode({800, 600}), "SFML window"); + + const sf::Texture texture("cute_image.jpg"); + sf::Sprite sprite(texture); + + const sf::Font font("arial.ttf"); + sf::Text text(font, "Hello SFML", 50); + + sf::Music music("nice_music.ogg"); + music.play(); + + while (window.isOpen()) + { + while (const std::optional event = window.pollEvent()) + { + if (event->is()) + window.close(); + } + + window.clear(); + window.draw(sprite); + window.draw(text); + window.display(); + } +}