Setting up SFML with cmake.
Setting up sfml with cmake.
Audio Library Requirement :
Root CMakeLists.txt file.
src dir CMakeLists.txt
vendors directory CMakeLists.txt
vendors sfml directory CMakeLists.txt
include(FetchContent)
FetchContent_Declare(
sfml
GIT_REPOSITORY https://github.com/SFML/SFML.git
GIT_TAG master
)
FetchContent_MakeAvailable(sfml)
main.cpp code
#include <SFML/Window.hpp>
int main()
{
sf::Window window(sf::VideoMode({800, 600}), "My window");
// run the program as long as the window is open
while (window.isOpen())
{
// check all the window's events that were triggered since the last iteration of the loop
while (const std::optional event = window.pollEvent())
{
// "close requested" event: we close the window
if (event->is<sf::Event::Closed>())
window.close();
}
}
}