Skip to content

Commit

Permalink
Use SFML 3
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisThrasher committed May 11, 2024
1 parent 4a3b745 commit 7b2117c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
13 changes: 2 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,10 @@ option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
include(FetchContent)
FetchContent_Declare(SFML
GIT_REPOSITORY https://github.com/SFML/SFML.git
GIT_TAG 2.6.x)
GIT_TAG master)
FetchContent_MakeAvailable(SFML)

add_executable(CMakeSFMLProject src/main.cpp)
target_link_libraries(CMakeSFMLProject PRIVATE sfml-graphics)
target_compile_features(CMakeSFMLProject PRIVATE cxx_std_17)

if(WIN32)
add_custom_command(
TARGET CMakeSFMLProject
COMMENT "Copy OpenAL DLL"
PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${SFML_SOURCE_DIR}/extlibs/bin/$<IF:$<EQUAL:${CMAKE_SIZEOF_VOID_P},8>,x64,x86>/openal32.dll $<TARGET_FILE_DIR:CMakeSFMLProject>
VERBATIM)
endif()
target_link_libraries(CMakeSFMLProject PRIVATE SFML::Graphics)

install(TARGETS CMakeSFMLProject)
6 changes: 3 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

int main()
{
auto window = sf::RenderWindow{ { 1920u, 1080u }, "CMake SFML Project" };
auto window = sf::RenderWindow{ sf::VideoMode{ { 1920u, 1080u } }, "CMake SFML Project" };
window.setFramerateLimit(144);

while (window.isOpen())
{
for (auto event = sf::Event{}; window.pollEvent(event);)
{
if (event.type == sf::Event::Closed)
if (event.is<sf::Event::Closed>())
{
window.close();
}
Expand All @@ -18,4 +18,4 @@ int main()
window.clear();
window.display();
}
}
}

0 comments on commit 7b2117c

Please sign in to comment.