Skip to content

Commit bbc431f

Browse files
committed
Use SFML 3
1 parent 4af7a18 commit bbc431f

File tree

3 files changed

+8
-18
lines changed

3 files changed

+8
-18
lines changed

.github/workflows/ci.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- { name: Windows VS2019, os: windows-2019 }
1919
- { name: Windows VS2022, os: windows-2022 }
2020
- { name: Linux GCC, os: ubuntu-latest }
21-
- { name: Linux Clang, os: ubuntu-latest, flags: -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ }
21+
- { name: Linux Clang, os: ubuntu-latest, flags: -DCMAKE_CXX_COMPILER=clang++ }
2222
- { name: macOS, os: macos-latest }
2323
config:
2424
- { name: Shared, flags: -DBUILD_SHARED_LIBS=TRUE }
@@ -27,7 +27,7 @@ jobs:
2727
steps:
2828
- name: Install Linux Dependencies
2929
if: runner.os == 'Linux'
30-
run: sudo apt-get update && sudo apt-get install libxrandr-dev libxcursor-dev libudev-dev libopenal-dev libflac-dev libvorbis-dev libgl1-mesa-dev libegl1-mesa-dev
30+
run: sudo apt-get update && sudo apt-get install libxrandr-dev libxcursor-dev libxi-dev libudev-dev libopenal-dev libflac-dev libvorbis-dev libgl1-mesa-dev libegl1-mesa-dev
3131

3232
- name: Checkout
3333
uses: actions/checkout@v4

CMakeLists.txt

+3-13
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,13 @@
1-
cmake_minimum_required(VERSION 3.16)
1+
cmake_minimum_required(VERSION 3.22)
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)