From cf486038c146292b5308c0c94994a62bdb96550f Mon Sep 17 00:00:00 2001 From: Martin Helmut Fieber Date: Wed, 17 Jul 2024 12:26:13 +0200 Subject: [PATCH 1/6] Updated code of conduct to v2.1 --- CODE_OF_CONDUCT.md | 45 +++++++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 20595a0..7673b83 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -6,8 +6,8 @@ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, -nationality, personal appearance, race, religion, or sexual identity -and orientation. +nationality, personal appearance, race, caste, color, religion, or sexual +identity and orientation. We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community. @@ -20,16 +20,21 @@ community include: * Demonstrating empathy and kindness toward other people * Being respectful of differing opinions, viewpoints, and experiences * Giving and gracefully accepting constructive feedback -* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience -* Focusing on what is best not just for us as individuals, but for the overall community +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the overall + community Examples of unacceptable behavior include: -* The use of sexualized language or imagery, and sexual attention or advances of any kind +* The use of sexualized language or imagery, and sexual attention or advances of + any kind * Trolling, insulting or derogatory comments, and personal or political attacks * Public or private harassment -* Publishing others' private information, such as a physical or email address, without their explicit permission -* Other conduct which could reasonably be considered inappropriate in a professional setting +* Publishing others' private information, such as a physical or email address, + without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting ## Enforcement Responsibilities @@ -47,7 +52,7 @@ decisions when appropriate. This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. -Examples of representing our community include using an official e-mail address, +Examples of representing our community include using an official email address, posting via an official social media account, or acting as an appointed representative at an online or offline event. @@ -55,7 +60,7 @@ representative at an online or offline event. Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at -[EMAIL](mailto:EMAIL). +[INSERT CONTACT METHOD]. All complaints will be reviewed and investigated promptly and fairly. All community leaders are obligated to respect the privacy and security of the @@ -77,15 +82,15 @@ behavior was inappropriate. A public apology may be requested. ### 2. Warning -**Community Impact**: A violation through a single incident or series -of actions. +**Community Impact**: A violation through a single incident or series of +actions. **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels -like social media. Violating these terms may lead to a temporary or -permanent ban. +like social media. Violating these terms may lead to a temporary or permanent +ban. ### 3. Temporary Ban @@ -104,25 +109,25 @@ Violating these terms may lead to a permanent ban. standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals. -**Consequence**: A permanent ban from any sort of public interaction within -the community. +**Consequence**: A permanent ban from any sort of public interaction within the +community. ## Attribution This Code of Conduct is adapted from the [Contributor Covenant][homepage], -version 2.0, available at -[https://www.contributor-covenant.org/version/2/0/code_of_conduct.html][v2.0]. +version 2.1, available at +[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder][Mozilla CoC]. For answers to common questions about this code of conduct, see the FAQ at -[https://www.contributor-covenant.org/faq][FAQ]. Translations are available -at [https://www.contributor-covenant.org/translations][translations]. +[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at +[https://www.contributor-covenant.org/translations][translations]. [homepage]: https://www.contributor-covenant.org -[v2.0]: https://www.contributor-covenant.org/version/2/0/code_of_conduct.html +[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html [Mozilla CoC]: https://github.com/mozilla/diversity From a5a1e9d336aad3557ff02a979b4a2423777d89ec Mon Sep 17 00:00:00 2001 From: Martin Helmut Fieber Date: Thu, 12 Sep 2024 11:28:02 +0200 Subject: [PATCH 2/6] Upgrade SDL3 and update documentation --- CMakeLists.txt | 2 +- CMakePresets.json | 6 ++++-- cmake/AppleBuild.cmake | 9 +++++++++ cmake/UniversalAppleBuild.cmake | 5 ----- docs/BuildAndExecution.md | 3 ++- docs/CMakePresets.md | 3 +++ docs/Packaging.md | 8 ++++---- docs/QuickStart.md | 29 +++++++++++++++++++++++++---- src/app/cmake/AppAssets.cmake | 2 -- src/app/cmake/packaging/Linux.cmake | 6 +++--- src/core/Core/Application.cpp | 4 ++-- src/core/Core/Window.cpp | 9 +++------ vendor/CMakeLists.txt | 8 ++++---- 13 files changed, 60 insertions(+), 34 deletions(-) create mode 100644 cmake/AppleBuild.cmake delete mode 100644 cmake/UniversalAppleBuild.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index ef4e028..b7165f7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.22) -include(cmake/UniversalAppleBuild.cmake) +include(cmake/AppleBuild.cmake) project( BasicGuiProjectSetup diff --git a/CMakePresets.json b/CMakePresets.json index 4321a5e..94e2693 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -25,7 +25,8 @@ "generator": "Xcode", "binaryDir": "build/xcode-debug", "cacheVariables": { - "CMAKE_BUILD_TYPE": "Debug" + "CMAKE_BUILD_TYPE": "Debug", + "CMAKE_OSX_ARCHITECTURES": "x86_64;arm64" }, "condition": { "type": "equals", @@ -39,7 +40,8 @@ "generator": "Xcode", "binaryDir": "build/xcode-release", "cacheVariables": { - "CMAKE_BUILD_TYPE": "Release" + "CMAKE_BUILD_TYPE": "Release", + "CMAKE_OSX_ARCHITECTURES": "x86_64;arm64" }, "condition": { "type": "equals", diff --git a/cmake/AppleBuild.cmake b/cmake/AppleBuild.cmake new file mode 100644 index 0000000..2377a4a --- /dev/null +++ b/cmake/AppleBuild.cmake @@ -0,0 +1,9 @@ +# This file needs to be included before calling `project`. +if (APPLE AND "${CMAKE_GENERATOR}" STREQUAL "Xcode") + # Define apple architecture for Release builds, use default. For an explicit + # universal executable use `x86_64;arm64`. + set(CMAKE_OSX_ARCHITECTURES "$(ARCHS_STANDARD)" CACHE INTERNAL "OS X architecture") + + # Support older macOS versions. + set(CMAKE_OSX_DEPLOYMENT_TARGET 10.15 CACHE STRING "Minimum OS X deployment version") +endif () diff --git a/cmake/UniversalAppleBuild.cmake b/cmake/UniversalAppleBuild.cmake deleted file mode 100644 index 1219050..0000000 --- a/cmake/UniversalAppleBuild.cmake +++ /dev/null @@ -1,5 +0,0 @@ -# Generate universal executable for Apple hardware for Release builds. -# This file needs to be included before calling `project`. -if (APPLE AND "${CMAKE_GENERATOR}" STREQUAL "Xcode") - set(CMAKE_OSX_ARCHITECTURES "$(ARCHS_STANDARD)") -endif () diff --git a/docs/BuildAndExecution.md b/docs/BuildAndExecution.md index 9a6d611..679b7e1 100644 --- a/docs/BuildAndExecution.md +++ b/docs/BuildAndExecution.md @@ -89,7 +89,8 @@ Run on a built target, in this example **debug**: ``` Though, even better is to use **Xcode as generator** to create app builds on macOS. Only difference in usage is running -CMake with `-GXcode`. If `CMAKE_OSX_ARCHITECTURES` is not set, it will create universal binaries on M1/2 macs. +CMake with `-GXcode` and setting the `CMAKE_OSX_ARCHITECTURES` variable, for example to `x86_64;arm64` for a universal +binaries. To run a **debug** build created with Xcode: diff --git a/docs/CMakePresets.md b/docs/CMakePresets.md index ec73c5d..59fa305 100644 --- a/docs/CMakePresets.md +++ b/docs/CMakePresets.md @@ -67,6 +67,9 @@ cpack --preset release ## Workflows +> [!IMPORTANT] +> Workflow presets are only available in CMake version 3.25 and up. + To list all available workflows, some dependent on the current system: ```shell diff --git a/docs/Packaging.md b/docs/Packaging.md index d7da87d..7bafb19 100644 --- a/docs/Packaging.md +++ b/docs/Packaging.md @@ -23,8 +23,8 @@ Packaging settings for the application executable are in `src/app/cmake/packagin The final application build for Apple devices should be built via the `Xcode` generator with CMake. ```shell -cmake -GXcode -DCMAKE_BUILD_TYPE=Release -B build/xcode -cmake --build build/xcode +cmake -GXcode -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" -B build/xcode +cmake --build build/xcode --config Release ``` ### Windows @@ -61,8 +61,8 @@ system**. Xcode should be used to create the release build for the application distributable. ```shell -cmake -GXcode -DCMAKE_BUILD_TYPE=Release -B build/xcode -cmake --build build/xcode +cmake -GXcode -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" -B build/xcode +cmake --build build/xcode --config Release cpack --config build/xcode/CPackConfig.cmake ``` diff --git a/docs/QuickStart.md b/docs/QuickStart.md index fb9830a..6e98011 100644 --- a/docs/QuickStart.md +++ b/docs/QuickStart.md @@ -4,6 +4,7 @@ Having all [requirements](README.md#requirements) set, here you can find how to ## Table of contents +- [TL;DR](#tldr) - [Build](#build) - [Execute](#execute) - [macOS](#macos) @@ -12,6 +13,24 @@ Having all [requirements](README.md#requirements) set, here you can find how to - [Distribution](#distribution) - [Tests](#tests) +## TL;DR + +> [!IMPORTANT] +> Workflow presets are only available in CMake version 3.25 and up. + +The quickest way possible to get an actual distributable from zero is using the available CMake workflows. For Linux and +Windows: + +```shell +cmake --workflow --preset dist +``` + +And for macOS with Xcode: + +```shell +cmake --workflow --preset xcode-dist +``` + ## Build Usually available build modes are `Debug`, `Release`, and `RelWithDebInfo`. @@ -30,12 +49,14 @@ cmake -GNinja -DCMAKE_BUILD_TYPE=Release -B build/release cmake --build build/release ``` -On macOS Xcode should be used as generator via `-GXcode`. For example creating a release build with XCode. +On macOS Xcode should be used as generator via `-GXcode`. For example creating a release build with XCode. It is also +necessary to specify the Apple architecture via `CMAKE_OSX_ARCHITECTURES`, for example for a universal executable using +the value `x86_64;arm64"`. ```shell -# Using Xcode -cmake -GXcode -DCMAKE_BUILD_TYPE=Release -B build/xcode -cmake --build build/xcode +# Using Xcode, create universal executable +cmake -GXcode -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" -B build/xcode +cmake --build build/xcode --config Release ``` ## Execute diff --git a/src/app/cmake/AppAssets.cmake b/src/app/cmake/AppAssets.cmake index 79e9b48..929e0fa 100644 --- a/src/app/cmake/AppAssets.cmake +++ b/src/app/cmake/AppAssets.cmake @@ -12,8 +12,6 @@ elseif (CMAKE_SYSTEM_NAME STREQUAL "Darwin") set(MACOSX_STATIC_ASSETS ${SHARED_STATIC_ASSETS} ${PROJECT_SOURCE_DIR}/src/assets/icons/icon.icns) - set_source_files_properties(${MACOSX_STATIC_ASSETS} - PROPERTIES MACOSX_PACKAGE_LOCATION ${CMAKE_INSTALL_DATADIR}) target_sources(${NAME} PUBLIC ${MACOSX_STATIC_ASSETS}) elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux") target_sources(${NAME} PRIVATE ${SHARED_STATIC_ASSETS}) diff --git a/src/app/cmake/packaging/Linux.cmake b/src/app/cmake/packaging/Linux.cmake index d58cf71..4cbbf52 100644 --- a/src/app/cmake/packaging/Linux.cmake +++ b/src/app/cmake/packaging/Linux.cmake @@ -23,10 +23,10 @@ install(DIRECTORY ${PROJECT_SOURCE_DIR}/src/assets/ DESTINATION ${CMAKE_INSTALL_ # Linux app icon setup configure_file( ${PROJECT_SOURCE_DIR}/src/app/Manifests/App.desktop.in - ${CMAKE_CURRENT_BINARY_DIR}/App.desktop + ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.desktop @ONLY) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/App.desktop +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.desktop DESTINATION share/applications) install(FILES ${PROJECT_SOURCE_DIR}/src/assets/icons/BaseAppIcon.png DESTINATION share/pixmaps - RENAME ${APP_NAME}_icon.png) + RENAME ${APP}_icon.png) diff --git a/src/core/Core/Application.cpp b/src/core/Core/Application.cpp index 67d1e6f..42933c9 100644 --- a/src/core/Core/Application.cpp +++ b/src/core/Core/Application.cpp @@ -16,8 +16,8 @@ Application::Application(const std::string& title) { APP_PROFILE_FUNCTION(); const unsigned int init_flags{SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_GAMEPAD}; - if (SDL_Init(init_flags) != 0) { - APP_ERROR("Error: %s\n", SDL_GetError()); + if (!SDL_Init(init_flags)) { + APP_ERROR("Error on SDL_Init(): %s\n", SDL_GetError()); m_exit_status = ExitStatus::FAILURE; } diff --git a/src/core/Core/Window.cpp b/src/core/Core/Window.cpp index 48fc40d..2d0fe61 100644 --- a/src/core/Core/Window.cpp +++ b/src/core/Core/Window.cpp @@ -20,8 +20,7 @@ Window::Window(const Settings& settings) m_settings.width, m_settings.height, SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIGH_PIXEL_DENSITY)), - m_renderer(SDL_CreateRenderer( - m_window, nullptr, SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED)) { + m_renderer(SDL_CreateRenderer(m_window, nullptr)) { APP_PROFILE_FUNCTION(); if (m_renderer == nullptr) { @@ -110,12 +109,10 @@ void Window::update() { // Debug panel if (m_show_debug_panel) { - SDL_RendererInfo info; - SDL_GetRendererInfo(m_renderer, &info); const ImGuiIO& io{ImGui::GetIO()}; ImGui::Begin("Debug panel", &m_show_debug_panel); - ImGui::Text("Current SDL_Renderer: %s", info.name); + ImGui::Text("Current SDL_Renderer: %s", SDL_GetRendererName(m_renderer)); ImGui::Text("User config path: %s", m_user_config_path.c_str()); ImGui::Text("Global font scaling %f", io.FontGlobalScale); ImGui::End(); @@ -127,7 +124,7 @@ void Window::update() { SDL_SetRenderDrawColor(m_renderer, 100, 100, 100, 255); SDL_RenderClear(m_renderer); - ImGui_ImplSDLRenderer3_RenderDrawData(ImGui::GetDrawData()); + ImGui_ImplSDLRenderer3_RenderDrawData(ImGui::GetDrawData(), m_renderer); SDL_RenderPresent(m_renderer); } diff --git a/vendor/CMakeLists.txt b/vendor/CMakeLists.txt index 1592e36..62932a8 100644 --- a/vendor/CMakeLists.txt +++ b/vendor/CMakeLists.txt @@ -11,25 +11,25 @@ FetchContent_Declare( FetchContent_Declare( fmt GIT_REPOSITORY "https://github.com/fmtlib/fmt.git" - GIT_TAG 10.2.1 + GIT_TAG 11.0.2 ) FetchContent_Declare( imgui GIT_REPOSITORY "https://github.com/ocornut/imgui.git" - GIT_TAG 085781f5ca5372d5fc804d7e44b5bf27a8994af7 # Branch: docking, date: 19.03.2024, 06:52 GMT+1 + GIT_TAG 68aa9a86ec933510073932980a0940742ecc833c # Branch: docking, date: 10.09.2024, 04:29 GMT+2 ) FetchContent_Declare( SDL3 GIT_REPOSITORY "https://github.com/libsdl-org/SDL.git" - GIT_TAG prerelease-3.1.1 + GIT_TAG 6e2f2428baca59280cb9bab47f7dac1159f94c46 # Branch: main, date: 12.09.2024, 08:31 GMT+2 ) FetchContent_Declare( spdlog GIT_REPOSITORY "https://github.com/gabime/spdlog.git" - GIT_TAG v1.13.0 + GIT_TAG v1.14.1 ) # Settings From cd866514ebaa5f829a1e4b339e8168697a3bf66f Mon Sep 17 00:00:00 2001 From: Martin Helmut Fieber Date: Thu, 12 Sep 2024 11:35:42 +0200 Subject: [PATCH 3/6] Add extended ImGui debug panels --- src/core/Core/Window.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/core/Core/Window.cpp b/src/core/Core/Window.cpp index 2d0fe61..1440206 100644 --- a/src/core/Core/Window.cpp +++ b/src/core/Core/Window.cpp @@ -88,7 +88,7 @@ void Window::update() { if (ImGui::BeginMenu("View")) { ImGui::MenuItem("Some Panel", nullptr, &m_show_some_panel); ImGui::MenuItem("ImGui Demo Panel", nullptr, &m_show_demo_panel); - ImGui::MenuItem("Debug Panel", nullptr, &m_show_debug_panel); + ImGui::MenuItem("Debug Panels", nullptr, &m_show_debug_panel); ImGui::EndMenu(); } @@ -111,7 +111,10 @@ void Window::update() { if (m_show_debug_panel) { const ImGuiIO& io{ImGui::GetIO()}; - ImGui::Begin("Debug panel", &m_show_debug_panel); + ImGui::ShowMetricsWindow(); + ImGui::ShowDebugLogWindow(); + + ImGui::Begin("App debug panel", &m_show_debug_panel); ImGui::Text("Current SDL_Renderer: %s", SDL_GetRendererName(m_renderer)); ImGui::Text("User config path: %s", m_user_config_path.c_str()); ImGui::Text("Global font scaling %f", io.FontGlobalScale); From 9f580e58e136d52042a5a9b000a80fc637cb858b Mon Sep 17 00:00:00 2001 From: Martin Helmut Fieber Date: Thu, 12 Sep 2024 11:47:58 +0200 Subject: [PATCH 4/6] Upgrade ImGui CMake usage --- vendor/imgui-setup/CMakeLists.txt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/vendor/imgui-setup/CMakeLists.txt b/vendor/imgui-setup/CMakeLists.txt index d77d35e..32e175e 100644 --- a/vendor/imgui-setup/CMakeLists.txt +++ b/vendor/imgui-setup/CMakeLists.txt @@ -1,7 +1,4 @@ -FetchContent_GetProperties(imgui) -if (NOT imgui_POPULATED) - FetchContent_Populate(imgui) -endif () +FetchContent_MakeAvailable(imgui) add_library(imgui ${imgui_SOURCE_DIR}/imgui.cpp ${imgui_SOURCE_DIR}/imgui.h From 8e4e7a9b6812985926eaabde8437507a540c2667 Mon Sep 17 00:00:00 2001 From: Martin Helmut Fieber Date: Sat, 16 Aug 2025 22:13:34 +0300 Subject: [PATCH 5/6] Upgrade project for CMake 4 --- .github/workflows/release.yml | 8 +-- .gitignore | 2 + CMakePresets.json | 22 +++---- LICENSE | 2 +- cmake/CompilerWarnings.cmake | 2 +- docs/Profiling.md | 5 +- packaging/CMakeLists.txt | 1 + src/core/CMakeLists.txt | 2 +- src/core/Core/Application.cpp | 3 +- src/core/Core/Resources.cpp | 18 ++++++ src/core/Core/Resources.hpp | 1 + src/core/Core/Window.cpp | 10 ++- template.sublime-project | 118 ++++++++++++++++++++++++++++++++++ vendor/CMakeLists.txt | 10 +-- 14 files changed, 171 insertions(+), 33 deletions(-) create mode 100644 src/core/Core/Resources.cpp create mode 100644 template.sublime-project diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f7b1352..b7276d1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,9 +2,9 @@ name: Release on: push: - branches: [ "main" ] + branches: ["main"] pull_request: - branches: [ "main" ] + branches: ["main"] env: BUILD_TYPE: Release @@ -13,7 +13,7 @@ jobs: build: strategy: matrix: - os: [ macos-14, ubuntu-latest, windows-latest ] + os: [macos-14, ubuntu-latest, windows-latest] runs-on: ${{ matrix.os }} @@ -21,7 +21,7 @@ jobs: - uses: actions/checkout@v4 - name: Configure CMake - run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} + run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DWARNINGS_AS_ERRORS=FALSE - name: Build run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} diff --git a/.gitignore b/.gitignore index 3185ed1..1faa45a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ # Application build output build/ distribution/ +.cache/ # Created by CPack when executing tests. Testing/ @@ -14,3 +15,4 @@ profile.json # User defined CMake preset file. CMakeUserPresets.json +*.sublime-workspace diff --git a/CMakePresets.json b/CMakePresets.json index 94e2693..86090e6 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -16,7 +16,8 @@ "generator": "Ninja", "binaryDir": "build/release", "cacheVariables": { - "CMAKE_BUILD_TYPE": "Release" + "CMAKE_BUILD_TYPE": "Release", + "WARNINGS_AS_ERRORS": "FALSE" } }, { @@ -41,7 +42,8 @@ "binaryDir": "build/xcode-release", "cacheVariables": { "CMAKE_BUILD_TYPE": "Release", - "CMAKE_OSX_ARCHITECTURES": "x86_64;arm64" + "CMAKE_OSX_ARCHITECTURES": "x86_64;arm64", + "WARNINGS_AS_ERRORS": "FALSE" }, "condition": { "type": "equals", @@ -62,9 +64,7 @@ "displayName": "Build Release", "configurePreset": "release", "configuration": "Release", - "targets": [ - "App" - ] + "targets": ["App"] }, { "name": "xcode-debug", @@ -82,9 +82,7 @@ "displayName": "Build Release (Xcode)", "configurePreset": "xcode-release", "configuration": "Release", - "targets": [ - "App" - ], + "targets": ["App"], "condition": { "type": "equals", "lhs": "${hostSystemName}", @@ -97,17 +95,13 @@ "name": "release", "displayName": "Distribute Release", "configurePreset": "release", - "configurations": [ - "Release" - ] + "configurations": ["Release"] }, { "name": "xcode-release", "displayName": "Distribute Release (Xcode)", "configurePreset": "xcode-release", - "configurations": [ - "Release" - ], + "configurations": ["Release"], "condition": { "type": "equals", "lhs": "${hostSystemName}", diff --git a/LICENSE b/LICENSE index a4cb892..2be16e6 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2024 +Copyright (c) 2025 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/cmake/CompilerWarnings.cmake b/cmake/CompilerWarnings.cmake index 4c7aa5c..cb314f6 100644 --- a/cmake/CompilerWarnings.cmake +++ b/cmake/CompilerWarnings.cmake @@ -2,7 +2,6 @@ function(set_project_warnings project_name) option(WARNINGS_AS_ERRORS "Treat compiler warnings as errors" TRUE) - message(STATUS "Treat compiler warnings as errors") set(MSVC_WARNINGS /W4 # Baseline reasonable warnings @@ -59,6 +58,7 @@ function(set_project_warnings project_name) ) if (WARNINGS_AS_ERRORS) + message(STATUS "Treat compiler warnings as errors") set(CLANG_WARNINGS ${CLANG_WARNINGS} -Werror) set(MSVC_WARNINGS ${MSVC_WARNINGS} /WX) endif () diff --git a/docs/Profiling.md b/docs/Profiling.md index f395182..b1942a5 100644 --- a/docs/Profiling.md +++ b/docs/Profiling.md @@ -68,8 +68,7 @@ int Application::run() { ## Show results -The resulting JSON file uses -the [Trace Event Format](https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview). Any +The resulting JSON file (`profile.json`) uses the [Trace Event Format](https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview). Any tool that can read this format can visualize the profiler data. For example the web tool [Perfetto](https://ui.perfetto.dev/) or Chromes built in [chrome://tracing](chrome://tracing). Just drag&drop the generated profiler JSON file onto the tool to load it. @@ -78,6 +77,6 @@ This is roughly how this looks like on Chrome. ![chrome-trace.png](assets/chrome-trace.png) -*** +--- Next up: [Logging](Logging.md) diff --git a/packaging/CMakeLists.txt b/packaging/CMakeLists.txt index be99060..58d80dd 100644 --- a/packaging/CMakeLists.txt +++ b/packaging/CMakeLists.txt @@ -44,6 +44,7 @@ set(CPACK_NSIS_MUI_UNWELCOMEFINISHPAGE_BITMAP ${CMAKE_CURRENT_LIST_DIR}/nsis\\\\ # Linux DEB settings set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT) +set(CPACK_DEBIAN_PACKAGE_DEPENDS "libsdl3-3.0-0") # Section list: https://packages.debian.org/unstable/ set(CPACK_DEBIAN_PACKAGE_SECTION Miscellaneous) set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Maintainer Name") diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 8b97088..19f4532 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -7,7 +7,7 @@ add_library(${NAME} STATIC Core/Application.cpp Core/Application.hpp Core/Window.cpp Core/Window.hpp Core/DPIHandler.cpp Core/DPIHandler.hpp - Core/Resources.hpp) + Core/Resources.hpp Core/Resources.cpp) # Define set of OS specific files to include if (CMAKE_SYSTEM_NAME STREQUAL "Windows") diff --git a/src/core/Core/Application.cpp b/src/core/Core/Application.cpp index 42933c9..216bb54 100644 --- a/src/core/Core/Application.cpp +++ b/src/core/Core/Application.cpp @@ -15,8 +15,7 @@ namespace App { Application::Application(const std::string& title) { APP_PROFILE_FUNCTION(); - const unsigned int init_flags{SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_GAMEPAD}; - if (!SDL_Init(init_flags)) { + if (!SDL_Init(SDL_INIT_VIDEO | SDL_INIT_GAMEPAD)) { APP_ERROR("Error on SDL_Init(): %s\n", SDL_GetError()); m_exit_status = ExitStatus::FAILURE; } diff --git a/src/core/Core/Resources.cpp b/src/core/Core/Resources.cpp new file mode 100644 index 0000000..f07f4d2 --- /dev/null +++ b/src/core/Core/Resources.cpp @@ -0,0 +1,18 @@ +#include "Core/Resources.hpp" + +#include + +#include + +#include "Core/Debug/Instrumentor.hpp" + +namespace App { + +bool Resources::exists(const std::filesystem::path& pathname) { + APP_PROFILE_FUNCTION(); + + struct stat buffer; + return (stat(pathname.generic_string().c_str(), &buffer) == 0); +} + +} // namespace App diff --git a/src/core/Core/Resources.hpp b/src/core/Core/Resources.hpp index 082cabf..3d89505 100644 --- a/src/core/Core/Resources.hpp +++ b/src/core/Core/Resources.hpp @@ -17,6 +17,7 @@ class Resources { [[nodiscard]] static std::filesystem::path resource_path(const std::filesystem::path& file_path); [[nodiscard]] static std::filesystem::path font_path(const std::string_view& font_file); + [[nodiscard]] static bool exists(const std::filesystem::path& pathname); }; } // namespace App diff --git a/src/core/Core/Window.cpp b/src/core/Core/Window.cpp index 1440206..f80b86a 100644 --- a/src/core/Core/Window.cpp +++ b/src/core/Core/Window.cpp @@ -47,8 +47,14 @@ Window::Window(const Settings& settings) const std::string font_path{Resources::font_path("Manrope.ttf").generic_string()}; const float font_scaling_factor{SDL_GetWindowDisplayScale(m_window)}; const float font_size{18.0F * font_scaling_factor}; - io.Fonts->AddFontFromFileTTF(font_path.c_str(), font_size); - io.FontDefault = io.Fonts->AddFontFromFileTTF(font_path.c_str(), font_size); + + if (Resources::exists(font_path)) { + io.Fonts->AddFontFromFileTTF(font_path.c_str(), font_size); + io.FontDefault = io.Fonts->AddFontFromFileTTF(font_path.c_str(), font_size); + } else { + APP_WARN("Could not find font file under: {}", font_path.c_str()); + } + io.FontGlobalScale = 1.0F / font_scaling_factor; // Setup Platform/Renderer backends diff --git a/template.sublime-project b/template.sublime-project new file mode 100644 index 0000000..50f513d --- /dev/null +++ b/template.sublime-project @@ -0,0 +1,118 @@ +{ + "folders": + [ + { + "path": ".", + } + ], + "settings": { + "cmake": { + "build_folder": "$folder/build", + "command_line_overrides": { + "CMAKE_POLICY_VERSION_MINIMUM": "3.5", + }, + }, + "LSP": { + "clangd": { + "initializationOptions": { + "clangd.clang-tidy": true, + }, + }, + }, + }, + "build_systems": + [ + { + "config": "Debug", + "env": + { + }, + "generator": "Unix Makefiles", + "name": "Debug", + "target": "cmake_build", + "variants": + [ + { + "build_target": "App", + "name": "App", + }, + { + "artifact": "src/app/App.app/Contents/MacOS/App", + "build_target": "App", + "name": "Run: App", + "target": "cmake_run", + }, + { + "artifact": "src/app/App.app/Contents/MacOS/App", + "build_target": "App", + "debug": true, + "name": "Run under LLDB: App", + "target": "cmake_run", + }, + { + "build_target": "Core", + "name": "Core", + }, + { + "build_target": "ResourcesTest", + "name": "ResourcesTest", + }, + { + "artifact": "src/core/Tests/ResourcesTest", + "build_target": "ResourcesTest", + "name": "Run: ResourcesTest", + "target": "cmake_run", + }, + { + "artifact": "src/core/Tests/ResourcesTest", + "build_target": "ResourcesTest", + "debug": true, + "name": "Run under LLDB: ResourcesTest", + "target": "cmake_run", + }, + { + "build_target": "SDL3-shared", + "name": "SDL3-shared", + }, + { + "build_target": "SDL3_test", + "name": "SDL3_test", + }, + { + "build_target": "SDL_uclibc", + "name": "SDL_uclibc", + }, + { + "build_target": "Settings", + "name": "Settings", + }, + { + "build_target": "TestRunner", + "name": "TestRunner", + }, + { + "build_target": "doctest_with_main", + "name": "doctest_with_main", + }, + { + "build_target": "fmt", + "name": "fmt", + }, + { + "build_target": "imgui", + "name": "imgui", + }, + { + "build_target": "spdlog", + "name": "spdlog", + }, + { + /*"build_target": "uninstall",*/ + "name": "ctest", + "target": "ctest_run", + }, + ], + "working_dir": "$folder/build", + } + ], +} diff --git a/vendor/CMakeLists.txt b/vendor/CMakeLists.txt index 62932a8..ee87e39 100644 --- a/vendor/CMakeLists.txt +++ b/vendor/CMakeLists.txt @@ -5,31 +5,31 @@ include(FetchContent) FetchContent_Declare( doctest GIT_REPOSITORY "https://github.com/onqtam/doctest.git" - GIT_TAG v2.4.11 + GIT_TAG v2.4.12 ) FetchContent_Declare( fmt GIT_REPOSITORY "https://github.com/fmtlib/fmt.git" - GIT_TAG 11.0.2 + GIT_TAG 11.2.0 ) FetchContent_Declare( imgui GIT_REPOSITORY "https://github.com/ocornut/imgui.git" - GIT_TAG 68aa9a86ec933510073932980a0940742ecc833c # Branch: docking, date: 10.09.2024, 04:29 GMT+2 + GIT_TAG b4311141947de17763d88f680c84c14379538388 # Branch: docking, date: 08.08.2024, 06:37 GMT+3 ) FetchContent_Declare( SDL3 GIT_REPOSITORY "https://github.com/libsdl-org/SDL.git" - GIT_TAG 6e2f2428baca59280cb9bab47f7dac1159f94c46 # Branch: main, date: 12.09.2024, 08:31 GMT+2 + GIT_TAG release-3.2.20 ) FetchContent_Declare( spdlog GIT_REPOSITORY "https://github.com/gabime/spdlog.git" - GIT_TAG v1.14.1 + GIT_TAG v1.15.3 ) # Settings From 642d8491f9cc943aaa1af5efbefb3cf95f21ceff Mon Sep 17 00:00:00 2001 From: Martin Helmut Fieber Date: Sat, 16 Aug 2025 22:17:03 +0300 Subject: [PATCH 6/6] Build SDL3 for console on Linux for Github Actions --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b7276d1..ef2e72d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,7 +21,7 @@ jobs: - uses: actions/checkout@v4 - name: Configure CMake - run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DWARNINGS_AS_ERRORS=FALSE + run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DSDL_UNIX_CONSOLE_BUILD=ON -DWARNINGS_AS_ERRORS=FALSE - name: Build run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}