Skip to content

Commit 48b6b93

Browse files
committed
cmake: make RelWithDebInfo the default configuration
1 parent 5447cb6 commit 48b6b93

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

CMakeLists.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
cmake_minimum_required(VERSION 3.16)
22

3+
if(NOT DEFINED CMAKE_BUILD_TYPE)
4+
set(cmake_build_type_undefined 1)
5+
endif()
6+
37
# See docs/release_checklist.md
48
project(SDL3 LANGUAGES C VERSION "3.1.7")
59

@@ -9,6 +13,23 @@ else()
913
set(SDL3_SUBPROJECT ON)
1014
endif()
1115

16+
# By default, configure SDL3 in RelWithDebInfo configuration
17+
if(NOT SDL3_SUBPROJECT)
18+
get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
19+
if(is_multi_config)
20+
# The first item in CMAKE_CONFIGURATION_TYPES is the default configuration
21+
if(DEFINED CMAKE_CONFIGURATION_TYPES AND "RelWithDebInfo" IN_LIST CMAKE_CONFIGURATION_TYPES)
22+
list(REMOVE_ITEM CMAKE_CONFIGURATION_TYPES "RelWithDebInfo")
23+
list(INSERT CMAKE_CONFIGURATION_TYPES 0 "RelWithDebInfo")
24+
set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING "CMake configuration types" FORCE)
25+
endif()
26+
else()
27+
if(cmake_build_type_undefined)
28+
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "CMake build type" FORCE)
29+
endif()
30+
endif()
31+
endif()
32+
1233
# CMake 3.0 expands the "if(${A})" in "set(OFF 1);set(A OFF);if(${A})" to "if(1)"
1334
# CMake 3.24+ emits a warning when not set.
1435
unset(OFF)

0 commit comments

Comments
 (0)