From 9bd0a519fc1709c0c6fe7f401b1fd55413d82b2a Mon Sep 17 00:00:00 2001 From: Erik Boasson Date: Sun, 5 Aug 2018 08:20:53 +0200 Subject: [PATCH] default to a RelWithDebInfo build if cmake is invoked without setting CMAKE_BUILD_TYPE Signed-off-by: Erik Boasson --- src/CMakeLists.txt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ce4d006..ef98c81 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -11,6 +11,17 @@ # cmake_minimum_required(VERSION 3.6) +# Set a default build type if none was specified +set(default_build_type "RelWithDebInfo") +if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + 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() + FUNCTION(PREPEND var prefix) SET(listVar "") FOREACH(f ${ARGN})