Add test to verify different consumptions of SFML

This commit is contained in:
Lukas Dürrenberger 2024-11-13 15:17:06 +01:00 committed by Lukas Dürrenberger
parent e21ba4dc95
commit 7c9bae3f6b
4 changed files with 64 additions and 0 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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)

30
test/integrate/main.cpp Normal file
View File

@ -0,0 +1,30 @@
#include <SFML/Audio.hpp>
#include <SFML/Graphics.hpp>
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<sf::Event::Closed>())
window.close();
}
window.clear();
window.draw(sprite);
window.draw(text);
window.display();
}
}