summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorAlan Antonuk <alan.antonuk@gmail.com>2021-04-01 05:47:34 +0000
committerAlan Antonuk <alan.antonuk@gmail.com>2021-03-31 23:26:41 -0700
commit3de048413d08e108d715311dc8a8c4694d53e05f (patch)
treeaf9c2048315e1dc01f5ec07a10dff5d563680b4c /CMakeLists.txt
parent6e630e98df3c4e868ba11793c274610ae950e375 (diff)
downloadrabbitmq-c-3de048413d08e108d715311dc8a8c4694d53e05f.tar.gz
cmake: modernize setting default build type
This is the method recommended on the kitware blog and will better handle other generators beyond Make and Ninja. Signed-off-by: GitHub <noreply@github.com>
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt9
1 files changed, 5 insertions, 4 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 10aabe7..42629e9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -38,10 +38,11 @@ string(REGEX MATCH "[0-9]+" _API_VERSION_PATCH ${_API_VERSION_PATCH})
# VERSION to match what is in autotools
set(VERSION ${_API_VERSION_MAJOR}.${_API_VERSION_MINOR}.${_API_VERSION_PATCH})
-if (CMAKE_GENERATOR MATCHES ".*(Make|Ninja).*"
- AND NOT CMAKE_BUILD_TYPE)
- set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
- message(STATUS "CMAKE_BUILD_TYPE not specified. Creating ${CMAKE_BUILD_TYPE} build")
+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_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
include(TestCInline)