@@ -171,21 +171,24 @@ mark_as_advanced(
171
171
CMAKE_SHARED_LINKER_FLAGS_COVERAGE
172
172
)
173
173
174
- if (CMAKE_CONFIGURATION_TYPES )
175
- set (CMAKE_CONFIGURATION_TYPES "RelWithDebInfo" "Release" "Debug" "MinSizeRel" "Coverage" )
176
- endif ()
177
-
178
- get_property (cached_cmake_build_type CACHE CMAKE_BUILD_TYPE PROPERTY TYPE )
179
- if (cached_cmake_build_type)
174
+ get_property (is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
175
+ set (default_build_type "RelWithDebInfo" )
176
+ if (is_multi_config)
177
+ set (CMAKE_CONFIGURATION_TYPES "${default_build_type} " "Release" "Debug" "MinSizeRel" "Coverage" CACHE STRING
178
+ "Supported configuration types."
179
+ FORCE
180
+ )
181
+ else ()
180
182
set_property (CACHE CMAKE_BUILD_TYPE PROPERTY
181
- STRINGS "RelWithDebInfo " "Release" "Debug" "MinSizeRel" "Coverage"
183
+ STRINGS "${default_build_type} " "Release" "Debug" "MinSizeRel" "Coverage"
182
184
)
183
- endif ()
184
-
185
- set (default_build_type "RelWithDebInfo" )
186
- if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES )
187
- message (STATUS "Setting build type to \" ${default_build_type} \" as none was specified" )
188
- set (CMAKE_BUILD_TYPE "${default_build_type} " CACHE STRING "Choose the type of build." FORCE)
185
+ if (NOT CMAKE_BUILD_TYPE )
186
+ message (STATUS "Setting build type to \" ${default_build_type} \" as none was specified" )
187
+ set (CMAKE_BUILD_TYPE "${default_build_type} " CACHE STRING
188
+ "Choose the type of build."
189
+ FORCE
190
+ )
191
+ endif ()
189
192
endif ()
190
193
191
194
include (TryAddCompileOption)
@@ -279,15 +282,15 @@ message("CFLAGS ................................ ${CMAKE_C_FLAGS}")
279
282
get_directory_property (compile_options COMPILE_OPTIONS)
280
283
string (REPLACE ";" " " compile_options "${compile_options} " )
281
284
message ("Compile options ....................... " ${compile_options} )
282
- if (DEFINED CMAKE_BUILD_TYPE )
285
+ if (NOT is_multi_config )
283
286
message ("Build type:" )
284
287
message (" - CMAKE_BUILD_TYPE ................... ${CMAKE_BUILD_TYPE} " )
285
288
string (TOUPPER "${CMAKE_BUILD_TYPE} " build_type )
286
289
message (" - CFLAGS ............................. ${CMAKE_C_FLAGS_${build_type} }" )
287
290
message (" - LDFLAGS for executables ............ ${CMAKE_EXE_LINKER_FLAGS_${build_type} }" )
288
291
message (" - LDFLAGS for shared libraries ....... ${CMAKE_SHARED_LINKER_FLAGS_${build_type} }" )
289
292
else ()
290
- message ("Available configurations .............. ${CMAKE_CONFIGURATION_TYPES} " )
293
+ message ("Supported configurations .............. ${CMAKE_CONFIGURATION_TYPES} " )
291
294
message ("RelWithDebInfo configuration:" )
292
295
message (" - CFLAGS ............................. ${CMAKE_C_FLAGS_RELWITHDEBINFO} " )
293
296
message (" - LDFLAGS for executables ............ ${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} " )
0 commit comments