[BUG] CMake uses extra hidden flags

In Debug configuration CMake uses \Zi flag, but when you try to create a custom configuration which is just a clone of Debug, that config won’t have \Zi flag

In my opinion this is a bug and CMake only should use flags which is included in “CMAKE_CXX_FLAGS_DEBUG”

Example code

set(CMAKE_CONFIGURATION_TYPES  "Debug;DebugEditor" CACHE STRING "Available build configurations" FORCE)

set(CMAKE_CXX_FLAGS_DEBUGEDITOR "${CMAKE_CXX_FLAGS_DEBUG}" CACHE STRING "CXX Flags for DebugEditor configuration" FORCE)
set(CMAKE_C_FLAGS_DEBUGEDITOR "${CMAKE_C_FLAGS_DEBUG}" CACHE STRING "C Flags for DebugEditor configuration" FORCE)
set(CMAKE_EXE_LINKER_FLAGS_DEBUGEDITOR "${CMAKE_EXE_LINKER_FLAGS_DEBUG}" CACHE STRING "Linker Flags for DebugEditor configuration" FORCE)

Am I misusing something or is this really a bug?

Maybe the DEBUG_CONFIGURATIONS global property can help you…

The /Zi flag is for MSVC debug information. See the CMAKE_MSVC_DEBUG_INFORMATION_FORMAT variable and corresponding MSVC_DEBUG_INFORMATION_FORMAT target property.

DEBUG_CONFIGURATIONS is only about the target_link_libraries command.

Thanks, that was it. Are there any other things that I should be aware of when using custom configurations?

See also CMAKE_MSVC_RUNTIME_LIBRARY.

Currently we have no official documentation on how to create custom configurations. I’ve opened CMake Issue 26454 for that.

I’m aware of CMAKE_MSVC_RUNTIME_LIBRARY
I was wondering since solution to original problem was an MSVC specific thing, could other compilers require something similar? (for same problem or maybe for their unique problems)
But since you didn’t mention them, I’m just gonna assume there aren’t any, unless anyone says otherwise.

Thanks for all the help, and documenting this sounds great!