From 708355f6e53ad885f5ce6a028ff10f5e4b9fd2d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hatvani=20Tam=C3=A1s?= Date: Fri, 13 Mar 2026 20:43:41 +0100 Subject: [PATCH] properly defining Debug --- CMakeLists.txt | 62 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 40 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 25a4817..4b718cb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,18 @@ cmake_minimum_required(VERSION 3.15) # Define the workspace/project project(SakuraVNE LANGUAGES CXX) +# ------------------------------------------------------------------------------ +# Default Build Type Configuration +# ------------------------------------------------------------------------------ +# If the user didn't specify a build type, default to Debug +if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + message(STATUS "Setting default build type to 'Debug'") + set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build." FORCE) + + # Provide dropdown options for tools like CMake GUI or IDEs + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") +endif() + # Enforce C++20 globally set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -38,7 +50,9 @@ add_subdirectory(libs/imgui) add_subdirectory(libs/imgui-node-editor) # 4. Catch2 -add_subdirectory(libs/catch2) +if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR NOT CMAKE_BUILD_TYPE) + add_subdirectory(libs/catch2) +endif() # ------------------------------------------------------------------------------ @@ -81,27 +95,29 @@ target_link_libraries(SakuraVNE PRIVATE # Tests Executable Target # ------------------------------------------------------------------------------ # These tests can use the Catch2-provided main, plus ALL your engine source files -add_executable(tests "SakuraVNE/test/test.cpp" ${SAKURA_SRCS}) +if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR NOT CMAKE_BUILD_TYPE) + add_executable(tests "SakuraVNE/test/test.cpp" ${SAKURA_SRCS}) -# The tests need the exact same include directories so your engine #includes work -target_include_directories(tests PRIVATE - "SakuraVNE/src" - "libs/spdlog/include" - "libs/imgui" - "libs/imgui/misc" - "libs/imgui/backends" - "libs/imgui-node-editor" - "libs/sdl3/include" -) + # The tests need the exact same include directories so your engine #includes work + target_include_directories(tests PRIVATE + "SakuraVNE/src" + "libs/spdlog/include" + "libs/imgui" + "libs/imgui/misc" + "libs/imgui/backends" + "libs/imgui-node-editor" + "libs/sdl3/include" + ) -# Link Catch2 AND the exact same dependencies your game uses -target_link_libraries(tests PRIVATE - Catch2::Catch2WithMain - ImGui - ImGuiNodeEditor - SDL3::SDL3 - spdlog::spdlog -) + # Link Catch2 AND the exact same dependencies your game uses + target_link_libraries(tests PRIVATE + Catch2::Catch2WithMain + ImGui + ImGuiNodeEditor + SDL3::SDL3 + spdlog::spdlog + ) +endif() # ------------------------------------------------------------------------------ @@ -122,8 +138,10 @@ elseif(UNIX AND NOT APPLE) target_link_libraries(SakuraVNE PRIVATE dl pthread) # Apply to Tests - target_compile_definitions(tests PRIVATE PLATFORM_LINUX) - target_link_libraries(tests PRIVATE dl pthread) + if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR NOT CMAKE_BUILD_TYPE) + target_compile_definitions(tests PRIVATE PLATFORM_LINUX) + target_link_libraries(tests PRIVATE dl pthread) + endif() endif() # Debug vs Release definitions for Game