diff --git a/CMakeLists.txt b/CMakeLists.txt index 6ed7d00..4b2bd11 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( BasicGuiProjectSetupOpenGL 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/UniversalAppleBuild.cmake b/cmake/AppleBuild.cmake similarity index 53% rename from cmake/UniversalAppleBuild.cmake rename to cmake/AppleBuild.cmake index edf74f9..2377a4a 100644 --- a/cmake/UniversalAppleBuild.cmake +++ b/cmake/AppleBuild.cmake @@ -1,7 +1,8 @@ # This file needs to be included before calling `project`. if (APPLE AND "${CMAKE_GENERATOR}" STREQUAL "Xcode") - # Generate universal executable for Apple hardware. - set(CMAKE_OSX_ARCHITECTURES "$(ARCHS_STANDARD)") + # 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") 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 17cd196..bce176c 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 4f8d807..acc86b1 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..fe4b40e 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 ${NAME}_icon.png) diff --git a/src/core/Core/Application.cpp b/src/core/Core/Application.cpp index 344d72d..719c131 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; } @@ -26,8 +26,6 @@ Application::Application(const std::string& title) { SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1); - SDL_SetHint(SDL_HINT_IME_SHOW_UI, "1"); - m_window = std::make_unique(Window::Settings{title}); } diff --git a/src/core/Core/Window.cpp b/src/core/Core/Window.cpp index baa2eca..0b8d8f4 100644 --- a/src/core/Core/Window.cpp +++ b/src/core/Core/Window.cpp @@ -69,7 +69,7 @@ Window::Window(const Settings& settings) Window::~Window() { APP_PROFILE_FUNCTION(); - SDL_GL_DeleteContext(m_gl_context); + SDL_GL_DestroyContext(m_gl_context); SDL_DestroyWindow(m_window); ImGui_ImplOpenGL3_Shutdown(); @@ -100,7 +100,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(); } @@ -121,7 +121,10 @@ void Window::update() { // Debug panel if (m_show_debug_panel) { - ImGui::Begin("Debug panel", &m_show_debug_panel); + ImGui::ShowMetricsWindow(); + ImGui::ShowDebugLogWindow(); + + ImGui::Begin("App debug panel", &m_show_debug_panel); ImGui::Text("User config path: %s", m_user_config_path.c_str()); ImGui::Text("Global font scaling %f", io.FontGlobalScale); ImGui::End(); diff --git a/vendor/CMakeLists.txt b/vendor/CMakeLists.txt index 2f8212c..28334c5 100644 --- a/vendor/CMakeLists.txt +++ b/vendor/CMakeLists.txt @@ -11,7 +11,7 @@ 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( @@ -23,19 +23,19 @@ FetchContent_Declare( 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 diff --git a/vendor/imgui-setup/CMakeLists.txt b/vendor/imgui-setup/CMakeLists.txt index 7d18925..9d1fdc0 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