From f72cc991292e3a94ec9ef09bb9c9b78e14ab39f4 Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Sat, 28 Dec 2024 01:23:06 +0100 Subject: [PATCH] cmake: make RelWithDebInfo the default configuration --- CMakeLists.txt | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4211753b..731d1f96 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,9 @@ cmake_minimum_required(VERSION 3.16...3.28) +if(NOT DEFINED CMAKE_BUILD_TYPE) + set(cmake_build_type_undefined 1) +endif() + list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") # See docs/release_checklist.md @@ -28,6 +32,24 @@ else() set(SDLIMAGE_ROOTPROJECT OFF) endif() + +# By default, configure in RelWithDebInfo configuration +if(NOT SDL3_SUBPROJECT) + get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) + if(is_multi_config) + # The first item in CMAKE_CONFIGURATION_TYPES is the default configuration + if(DEFINED CMAKE_CONFIGURATION_TYPES AND "RelWithDebInfo" IN_LIST CMAKE_CONFIGURATION_TYPES) + list(REMOVE_ITEM CMAKE_CONFIGURATION_TYPES "RelWithDebInfo") + list(INSERT CMAKE_CONFIGURATION_TYPES 0 "RelWithDebInfo") + set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING "CMake configuration types" FORCE) + endif() + else() + if(cmake_build_type_undefined) + set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "CMake build type" FORCE) + endif() + endif() +endif() + set(SDLIMAGE_SAMPLES_DEFAULT ${SDLIMAGE_ROOTPROJECT}) if(ANDROID) set(SDLIMAGE_SAMPLES_DEFAULT OFF)