@@ -170,21 +170,24 @@ mark_as_advanced(
170
170
CMAKE_SHARED_LINKER_FLAGS_COVERAGE
171
171
)
172
172
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 ()
179
181
set_property (CACHE CMAKE_BUILD_TYPE PROPERTY
180
- STRINGS "RelWithDebInfo " "Release" "Debug" "MinSizeRel" "Coverage"
182
+ STRINGS "${default_build_type} " "Release" "Debug" "MinSizeRel" "Coverage"
181
183
)
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 defined" )
186
+ set (CMAKE_BUILD_TYPE "${default_build_type} " CACHE STRING
187
+ "Choose the type of build."
188
+ FORCE
189
+ )
190
+ endif ()
188
191
endif ()
189
192
190
193
include (TryAddCompileOption)
@@ -273,15 +276,15 @@ message("CFLAGS ................................ ${CMAKE_C_FLAGS}")
273
276
get_directory_property (compile_options COMPILE_OPTIONS)
274
277
string (REPLACE ";" " " compile_options "${compile_options} " )
275
278
message ("Compile options ....................... " ${compile_options} )
276
- if (DEFINED CMAKE_BUILD_TYPE )
279
+ if (NOT is_multi_config )
277
280
message ("Build type:" )
278
281
message (" - CMAKE_BUILD_TYPE ................... ${CMAKE_BUILD_TYPE} " )
279
282
string (TOUPPER "${CMAKE_BUILD_TYPE} " build_type )
280
283
message (" - CFLAGS ............................. ${CMAKE_C_FLAGS_${build_type} }" )
281
284
message (" - LDFLAGS for executables ............ ${CMAKE_EXE_LINKER_FLAGS_${build_type} }" )
282
285
message (" - LDFLAGS for shared libraries ....... ${CMAKE_SHARED_LINKER_FLAGS_${build_type} }" )
283
286
else ()
284
- message ("Available configurations .............. ${CMAKE_CONFIGURATION_TYPES} " )
287
+ message ("Supported configurations .............. ${CMAKE_CONFIGURATION_TYPES} " )
285
288
message ("RelWithDebInfo configuration:" )
286
289
message (" - CFLAGS ............................. ${CMAKE_C_FLAGS_RELWITHDEBINFO} " )
287
290
message (" - LDFLAGS for executables ............ ${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} " )
0 commit comments