Skip to content

Commit 8e4e7a9

Browse files
committed
Upgrade project for CMake 4
1 parent 9f580e5 commit 8e4e7a9

File tree

14 files changed

+171
-33
lines changed

14 files changed

+171
-33
lines changed

.github/workflows/release.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: Release
22

33
on:
44
push:
5-
branches: [ "main" ]
5+
branches: ["main"]
66
pull_request:
7-
branches: [ "main" ]
7+
branches: ["main"]
88

99
env:
1010
BUILD_TYPE: Release
@@ -13,15 +13,15 @@ jobs:
1313
build:
1414
strategy:
1515
matrix:
16-
os: [ macos-14, ubuntu-latest, windows-latest ]
16+
os: [macos-14, ubuntu-latest, windows-latest]
1717

1818
runs-on: ${{ matrix.os }}
1919

2020
steps:
2121
- uses: actions/checkout@v4
2222

2323
- name: Configure CMake
24-
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
24+
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DWARNINGS_AS_ERRORS=FALSE
2525

2626
- name: Build
2727
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Application build output
22
build/
33
distribution/
4+
.cache/
45

56
# Created by CPack when executing tests.
67
Testing/
@@ -14,3 +15,4 @@ profile.json
1415

1516
# User defined CMake preset file.
1617
CMakeUserPresets.json
18+
*.sublime-workspace

CMakePresets.json

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"generator": "Ninja",
1717
"binaryDir": "build/release",
1818
"cacheVariables": {
19-
"CMAKE_BUILD_TYPE": "Release"
19+
"CMAKE_BUILD_TYPE": "Release",
20+
"WARNINGS_AS_ERRORS": "FALSE"
2021
}
2122
},
2223
{
@@ -41,7 +42,8 @@
4142
"binaryDir": "build/xcode-release",
4243
"cacheVariables": {
4344
"CMAKE_BUILD_TYPE": "Release",
44-
"CMAKE_OSX_ARCHITECTURES": "x86_64;arm64"
45+
"CMAKE_OSX_ARCHITECTURES": "x86_64;arm64",
46+
"WARNINGS_AS_ERRORS": "FALSE"
4547
},
4648
"condition": {
4749
"type": "equals",
@@ -62,9 +64,7 @@
6264
"displayName": "Build Release",
6365
"configurePreset": "release",
6466
"configuration": "Release",
65-
"targets": [
66-
"App"
67-
]
67+
"targets": ["App"]
6868
},
6969
{
7070
"name": "xcode-debug",
@@ -82,9 +82,7 @@
8282
"displayName": "Build Release (Xcode)",
8383
"configurePreset": "xcode-release",
8484
"configuration": "Release",
85-
"targets": [
86-
"App"
87-
],
85+
"targets": ["App"],
8886
"condition": {
8987
"type": "equals",
9088
"lhs": "${hostSystemName}",
@@ -97,17 +95,13 @@
9795
"name": "release",
9896
"displayName": "Distribute Release",
9997
"configurePreset": "release",
100-
"configurations": [
101-
"Release"
102-
]
98+
"configurations": ["Release"]
10399
},
104100
{
105101
"name": "xcode-release",
106102
"displayName": "Distribute Release (Xcode)",
107103
"configurePreset": "xcode-release",
108-
"configurations": [
109-
"Release"
110-
],
104+
"configurations": ["Release"],
111105
"condition": {
112106
"type": "equals",
113107
"lhs": "${hostSystemName}",

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2024 <copyright holders>
3+
Copyright (c) 2025 <copyright holders>
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

cmake/CompilerWarnings.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
function(set_project_warnings project_name)
44
option(WARNINGS_AS_ERRORS "Treat compiler warnings as errors" TRUE)
5-
message(STATUS "Treat compiler warnings as errors")
65

76
set(MSVC_WARNINGS
87
/W4 # Baseline reasonable warnings
@@ -59,6 +58,7 @@ function(set_project_warnings project_name)
5958
)
6059

6160
if (WARNINGS_AS_ERRORS)
61+
message(STATUS "Treat compiler warnings as errors")
6262
set(CLANG_WARNINGS ${CLANG_WARNINGS} -Werror)
6363
set(MSVC_WARNINGS ${MSVC_WARNINGS} /WX)
6464
endif ()

docs/Profiling.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ int Application::run() {
6868

6969
## Show results
7070

71-
The resulting JSON file uses
72-
the [Trace Event Format](https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview). Any
71+
The resulting JSON file (`profile.json`) uses the [Trace Event Format](https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview). Any
7372
tool that can read this format can visualize the profiler data. For example the web
7473
tool [Perfetto](https://ui.perfetto.dev/) or Chromes built in [chrome://tracing](chrome://tracing). Just drag&drop the
7574
generated profiler JSON file onto the tool to load it.
@@ -78,6 +77,6 @@ This is roughly how this looks like on Chrome.
7877

7978
![chrome-trace.png](assets/chrome-trace.png)
8079

81-
***
80+
---
8281

8382
Next up: [Logging](Logging.md)

packaging/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ set(CPACK_NSIS_MUI_UNWELCOMEFINISHPAGE_BITMAP ${CMAKE_CURRENT_LIST_DIR}/nsis\\\\
4444

4545
# Linux DEB settings
4646
set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)
47+
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libsdl3-3.0-0")
4748
# Section list: https://packages.debian.org/unstable/
4849
set(CPACK_DEBIAN_PACKAGE_SECTION Miscellaneous)
4950
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Maintainer Name")

src/core/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ add_library(${NAME} STATIC
77
Core/Application.cpp Core/Application.hpp
88
Core/Window.cpp Core/Window.hpp
99
Core/DPIHandler.cpp Core/DPIHandler.hpp
10-
Core/Resources.hpp)
10+
Core/Resources.hpp Core/Resources.cpp)
1111

1212
# Define set of OS specific files to include
1313
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")

src/core/Core/Application.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ namespace App {
1515
Application::Application(const std::string& title) {
1616
APP_PROFILE_FUNCTION();
1717

18-
const unsigned int init_flags{SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_GAMEPAD};
19-
if (!SDL_Init(init_flags)) {
18+
if (!SDL_Init(SDL_INIT_VIDEO | SDL_INIT_GAMEPAD)) {
2019
APP_ERROR("Error on SDL_Init(): %s\n", SDL_GetError());
2120
m_exit_status = ExitStatus::FAILURE;
2221
}

src/core/Core/Resources.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include "Core/Resources.hpp"
2+
3+
#include <sys/stat.h>
4+
5+
#include <filesystem>
6+
7+
#include "Core/Debug/Instrumentor.hpp"
8+
9+
namespace App {
10+
11+
bool Resources::exists(const std::filesystem::path& pathname) {
12+
APP_PROFILE_FUNCTION();
13+
14+
struct stat buffer;
15+
return (stat(pathname.generic_string().c_str(), &buffer) == 0);
16+
}
17+
18+
} // namespace App

0 commit comments

Comments
 (0)