@@ -170,21 +170,24 @@ mark_as_advanced(
170170 CMAKE_SHARED_LINKER_FLAGS_COVERAGE
171171)
172172
173- if (CMAKE_CONFIGURATION_TYPES )
174- set (CMAKE_CONFIGURATION_TYPES "RelWithDebInfo" "Release" "Debug" "MinSizeRel" "Coverage" )
175- endif ()
176-
177- get_property (cached_cmake_build_type CACHE CMAKE_BUILD_TYPE PROPERTY TYPE )
178- if (cached_cmake_build_type)
173+ get_property (is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
174+ set (default_build_type "RelWithDebInfo" )
175+ if (is_multi_config)
176+ set (CMAKE_CONFIGURATION_TYPES "${default_build_type} " "Release" "Debug" "MinSizeRel" "Coverage" CACHE STRING
177+ "Supported configuration types."
178+ FORCE
179+ )
180+ else ()
179181 set_property (CACHE CMAKE_BUILD_TYPE PROPERTY
180- STRINGS "RelWithDebInfo " "Release" "Debug" "MinSizeRel" "Coverage"
182+ STRINGS "${default_build_type} " "Release" "Debug" "MinSizeRel" "Coverage"
181183 )
182- endif ()
183-
184- set (default_build_type "RelWithDebInfo" )
185- if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES )
186- message (STATUS "Setting build type to \" ${default_build_type} \" as none was specified" )
187- set (CMAKE_BUILD_TYPE "${default_build_type} " CACHE STRING "Choose the type of build." FORCE)
184+ if (NOT CMAKE_BUILD_TYPE )
185+ message (STATUS "Setting build type to \" ${default_build_type} \" as none was specified" )
186+ set (CMAKE_BUILD_TYPE "${default_build_type} " CACHE STRING
187+ "Choose the type of build."
188+ FORCE
189+ )
190+ endif ()
188191endif ()
189192
190193include (TryAddCompileOption)
@@ -273,15 +276,15 @@ message("CFLAGS ................................ ${CMAKE_C_FLAGS}")
273276get_directory_property (compile_options COMPILE_OPTIONS)
274277string (REPLACE ";" " " compile_options "${compile_options} " )
275278message ("Compile options ....................... " ${compile_options} )
276- if (DEFINED CMAKE_BUILD_TYPE )
279+ if (NOT is_multi_config )
277280 message ("Build type:" )
278281 message (" - CMAKE_BUILD_TYPE ................... ${CMAKE_BUILD_TYPE} " )
279282 string (TOUPPER "${CMAKE_BUILD_TYPE} " build_type )
280283 message (" - CFLAGS ............................. ${CMAKE_C_FLAGS_${build_type} }" )
281284 message (" - LDFLAGS for executables ............ ${CMAKE_EXE_LINKER_FLAGS_${build_type} }" )
282285 message (" - LDFLAGS for shared libraries ....... ${CMAKE_SHARED_LINKER_FLAGS_${build_type} }" )
283286else ()
284- message ("Available configurations .............. ${CMAKE_CONFIGURATION_TYPES} " )
287+ message ("Supported configurations .............. ${CMAKE_CONFIGURATION_TYPES} " )
285288 message ("RelWithDebInfo configuration:" )
286289 message (" - CFLAGS ............................. ${CMAKE_C_FLAGS_RELWITHDEBINFO} " )
287290 message (" - LDFLAGS for executables ............ ${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} " )
0 commit comments