cmake: make sure that at least one build type is defined (default: Release)

This commit is contained in:
suter_a 2018-06-06 12:57:38 +02:00
parent 92f230e220
commit 1c901f73ba

View File

@ -14,6 +14,18 @@ option(try_OpenMP "try to use OpenMP if available" ON)
set(qt_version AUTO CACHE STRING "provide a specific Qt version to be used.")
set_property(CACHE qt_version PROPERTY STRINGS AUTO 3 4 5)
#--- set a default build type if none was specified ---------------------------
set(default_build_type "Release")
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()
#--- perform some checks and generate the config.h ----------------------------
include(CheckTypeSize)
include(CheckIncludeFiles)
@ -191,6 +203,9 @@ message(" -------")
message("")
message(" ${CMAKE_HOST_SYSTEM_NAME} ${CMAKE_SYSTEM_PROCESSOR} - ${CMAKE_HOST_SYSTEM_VERSION}")
message("")
message(" Build Type: ${CMAKE_BUILD_TYPE}")
message(" -----------")
message("")
message(" Requirements:")
message(" -------------")
message("")