cmake: set a CMAKE_BUILD_TYPE if none was specified

Because the default "empty" CMAKE_BUILD_TYPE is a weird default

Change-Id: I5768f67aa85dce4108e421d2f4eacdfb1cb5beb0
Reviewed-by: Kevin Funk <kevin.funk@kdab.com>
This commit is contained in:
Albert Astals Cid 2019-02-19 16:38:11 +01:00
parent b88110a3d7
commit 632d014afd

View File

@ -1,3 +1,15 @@
## Set a default build type if none was specified
set(_default_build_type "Release")
if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
set(_default_build_type "Debug")
endif()
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_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") # Set the possible values of build type for cmake-gui
endif()
## Force C++ standard, do not fall back, do not use compiler extensions
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)