Visual Studio 2022 CMake Presets

1.5k Views Asked by At

I'm using CMake in my project and I'm beginning to explore the possibilities of CMakePresets

I managed to create a default windows preset. Currently my Windows default preset sets the CMAKE_BUILD_TYPE to debug. now I'd like to select the config in the left drop-down and the Build Type in the right drop-down (see image)

Is this somehow possible?

Thx for your help

enter image description here

1

There are 1 best solutions below

0
On BEST ANSWER

I'm just understanding this myself, but I believe what you want is to set up "buildPresets" like so:

{
   "name": "windows-debug",
   "displayName": "Debug",
   "configurePreset": "windows-default",
   "configuration": "Debug"
},
{
   "name": "windows-release",
   "displayName": "Release",
   "configurePreset": "windows-default",
   "configuration": "Release"
}

I believe "configuration" should be used instead of CMAKE_BUILD_TYPE as its identical to the flag --config as in

> cmake --build . --config Release

Source: https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html#build-preset