Skip to content

Commit 7bc4284

Browse files
committed
Use SFML 3
1 parent 9e674d9 commit 7bc4284

File tree

2 files changed

+5
-15
lines changed

2 files changed

+5
-15
lines changed

CMakeLists.txt

+2-12
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,12 @@ cmake_minimum_required(VERSION 3.16)
22
project(CMakeSFMLProject LANGUAGES CXX)
33

44
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
5-
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
65

76
include(FetchContent)
87
FetchContent_Declare(SFML
98
GIT_REPOSITORY https://github.com/SFML/SFML.git
10-
GIT_TAG 2.6.x)
9+
GIT_TAG master)
1110
FetchContent_MakeAvailable(SFML)
1211

1312
add_executable(main src/main.cpp)
14-
target_link_libraries(main PRIVATE sfml-graphics)
15-
target_compile_features(main PRIVATE cxx_std_17)
16-
17-
if(WIN32)
18-
add_custom_command(
19-
TARGET main
20-
COMMENT "Copy OpenAL DLL"
21-
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:main>
22-
VERBATIM)
23-
endif()
13+
target_link_libraries(main PRIVATE SFML::Graphics)

src/main.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
int main()
44
{
5-
auto window = sf::RenderWindow{ { 1920u, 1080u }, "CMake SFML Project" };
5+
auto window = sf::RenderWindow{ sf::VideoMode{ { 1920u, 1080u } }, "CMake SFML Project" };
66
window.setFramerateLimit(144);
77

88
while (window.isOpen())
99
{
10-
for (auto event = sf::Event{}; window.pollEvent(event);)
10+
while (const auto event = window.pollEvent())
1111
{
12-
if (event.type == sf::Event::Closed)
12+
if (event.is<sf::Event::Closed>())
1313
{
1414
window.close();
1515
}

0 commit comments

Comments
 (0)