CMAKE_BUILD_TYPE, Presets, Multi-config generators

CMake documentation on Build Configurations says that " For multi-configuration generators like Visual Studio,…, the configuration is chosen by the user at build time and CMAKE_BUILD_TYPE is ignored".

But, then, I see that official blogs and videos from Microsoft giving examples of Visual Studio presets that have lines such as “CMAKE_BUILD_TYPE: Debug” under the “cacheVariables” section of the configuration presets.

So, isn’t " CMAKE_BUILD_TYPE" really ignored by multi-config IDEs such as Visual Studio contrary to what the above referenced documentation page says?

CMAKE_BUILD_TYPE is definitely ignored by multi-config generators. But projects are often (wrongly) written assuming a single config generator is used, and they might always (try to) set or use CMAKE_BUILD_TYPE even when it isn’t appropriate. Some IDEs also make the same mistake. For example, CLion only recently stopped setting CMAKE_BUILD_TYPE when using a multi-config generator.

Note that you can use a single config generator with the Visual Studio toolchain. The blogs, videos and examples you’re looking at may be in that category. But if they are setting CMAKE_BUILD_TYPE and using the Visual Studio generator rather than a generator like Ninja, that’s wrong.

One example I had seen and followed was this one with an example being shown at the 10:50 time point. I had considered it a trustworthy example since it was provided by the product manager associated with adding the presets feature to Visual Studio :).