Changing project config type in VS cmake-based project

Ivanov, Aleksandr 0 Reputation points
2023-09-07T20:16:24+00:00

Hello!

I'm trying to clarify the VS behavior with Cmake projects that use presets, specifically, how do I switch the configuration type of the build. Here's a basic cmakepresets.json:

{
    "version": 3,
    "cmakeMinimumRequired": {
        "major": 3,
        "minor": 15,
        "patch": 0
    },
    "configurePresets": [
        {
            "name": "win32",
            "generator": "Visual Studio 17 2022",
            "architecture": "x64"
        }
    ]
}


When I open the project as a folder with cmakelists.txt, I get the following parameters for the configuration type:
User's image

Only "Debug" is available. Although, if I create a project like cmake -B build/win32 --preset win32 I would be able to build it with different --config values that one would expect to be available with CMake. If I open the generated solution in build/win32 with VS, I can see the expected values.

User's image

An idea what's happening here and how can I switch between different configuration types when I open a folder as a cmake project with presets?

Thank you,

Aleksandr.

Community Center | Not monitored
{count} votes

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.