From 24954bf6ed3db2fdcc17f717fd643266a7a8569d Mon Sep 17 00:00:00 2001 From: akallabeth Date: Thu, 17 Oct 2024 15:54:41 +0200 Subject: [PATCH] [cmake] make CMAKE_BUILD_TYPE selectable --- cmake/CommonConfigOptions.cmake | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/cmake/CommonConfigOptions.cmake b/cmake/CommonConfigOptions.cmake index 7b0e147ad..ce09dedf3 100644 --- a/cmake/CommonConfigOptions.cmake +++ b/cmake/CommonConfigOptions.cmake @@ -30,8 +30,16 @@ if (NOT ANDROID) endif() # Default to release build type -if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE "Release" CACHE STRING "project default") +if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + # Set a default build type if none was specified + set(default_build_type "Release") + + message(STATUS "Setting build type to '${default_build_type}' as none was specified.") + set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE + STRING "Choose the type of build." FORCE) + # Set the possible values of build type for cmake-gui + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY + STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") endif() include(PlatformDefaults)