mirror of
https://github.com/SFML/SFML.git
synced 2024-11-24 20:31:05 +08:00
Add test to verify different consumptions of SFML
This commit is contained in:
parent
e21ba4dc95
commit
7c9bae3f6b
14
test/integrate/FetchContent/CMakeLists.txt
Normal file
14
test/integrate/FetchContent/CMakeLists.txt
Normal 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)
|
11
test/integrate/FindPackage/CMakeLists.txt
Normal file
11
test/integrate/FindPackage/CMakeLists.txt
Normal 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)
|
9
test/integrate/SubDirectory/CMakeLists.txt
Normal file
9
test/integrate/SubDirectory/CMakeLists.txt
Normal 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
30
test/integrate/main.cpp
Normal 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();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user