vscode-cmake-tools icon indicating copy to clipboard operation
vscode-cmake-tools copied to clipboard

[Bug] Select variant: does nothing on quickstart projects (Switching Debug & Release and other modes.)

Open Saladin1812 opened this issue 5 months ago • 7 comments

Brief Issue Summary

I have a newly created cmake project created using cmake: Quickstart. And when choosing a preset it showed me GCC and Clang (I am on Linux and have both installed). Choosing either. After that it generates a CMakePresets.json with whichever compiler you chose and with the Debug Build type.

Now if i want to test a release build selecting a variant basically does nothing. It doesnt change either the CMakePresets.json and neither does it affect CMakeCache.txt inside the build directory . the CMAKE_BUILD_TYPE is still Debug. So it is really confusing. Also the chosen variant is not shown anywhere on the status bar or the cmake sidebar but the documentation states it is written there.

Here is the video ->

https://github.com/user-attachments/assets/1dc55eff-1655-4e55-862c-ba0167182a5a

CMake Tools Diagnostics

{
  "os": "linux",
  "vscodeVersion": "1.103.2",
  "cmtVersion": "1.21.36",
  "configurations": [
    {
      "folder": "/home/saladin/Repos/CppProjects",
      "cmakeVersion": "3.31.7",
      "configured": true,
      "generator": "Unix Makefiles",
      "usesPresets": true,
      "compilers": {
        "C": "/run/current-system/sw/bin/gcc",
        "CXX": "/run/current-system/sw/bin/g++"
      }
    }
  ],
  "cpptoolsIntegration": {
    "isReady": true,
    "hasCodeModel": true,
    "activeBuildType": "Debug",
    "buildTypesSeen": [
      "Debug"
    ],
    "requests": [],
    "responses": [],
    "partialMatches": [],
    "targetCount": 1,
    "executablesCount": 1,
    "librariesCount": 0,
    "targets": [
      {
        "name": "firstProj",
        "type": "EXECUTABLE"
      }
    ]
  },
  "settings": [
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": true
    }
  ]
}

Debug Log

[main] Building folder: /home/saladin/Repos/CppProjects/out/build/Cmake 
[build] Starting build
[proc] Executing command: /run/current-system/sw/bin/cmake --build /home/saladin/Repos/CppProjects/out/build/Cmake --
[build] [100%] Built target firstProj
[driver] Build completed: 00:00:00.089
[build] Build finished with exit code 0

Additional Information

It would be great to improve the UX when it comes to selecting the variants, and easily switch or display it in the status bar.

Saladin1812 avatar Sep 09 '25 15:09 Saladin1812

The issue also might be that it still uses old Kit + Variant but generated the preset model.

I also don't have access to

CMake: Select Configure Preset

Or Any preset related command whatsoever.

Saladin1812 avatar Sep 09 '25 17:09 Saladin1812

That seems to be the case which is another bug

also

I tried forcing cmake to use the preset system

"cmake.useCMakePresets" = "always";

And also changed the Preset to include the following

{
    "version": 8,
    "configurePresets": [
        {
            "name": "Debug",
            "displayName": "GCC 14.3.0 x86_64-unknown-linux-gnu",
            "description": "Using compilers: C = /run/current-system/sw/bin/gcc, CXX = /run/current-system/sw/bin/g++",
            "binaryDir": "${sourceDir}/out/build/${presetName}",
            "cacheVariables": {
                "CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}",
                "CMAKE_C_COMPILER": "/run/current-system/sw/bin/gcc",
                "CMAKE_CXX_COMPILER": "/run/current-system/sw/bin/g++",
                "CMAKE_BUILD_TYPE": "Debug"
            }
        },
        {
            "name": "Release",
            "displayName": "GCC 14.3.0 x86_64-unknown-linux-gnu",
            "description": "Using compilers: C = /run/current-system/sw/bin/gcc, CXX = /run/current-system/sw/bin/g++",
            "binaryDir": "${sourceDir}/out/build/${presetName}",
            "cacheVariables": {
                "CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}",
                "CMAKE_C_COMPILER": "/run/current-system/sw/bin/gcc",
                "CMAKE_CXX_COMPILER": "/run/current-system/sw/bin/g++",
                "CMAKE_BUILD_TYPE": "Release"
            }
        }
    ],

    "buildPresets": [
    { "name": "Debug", "configurePreset": "Debug" },
    { "name": "Release", "configurePreset": "Release" }
  ]
}

But the presets show only "Default" & "Release". Please see to this.

Saladin1812 avatar Sep 09 '25 17:09 Saladin1812

Hi @SaladinAyyub , thank you for reporting this issue. We tried to check this issue in Visual Studio Code v1.103.2 + CMake Tools v1.21.36. We can switch between Debug and Release configurations. Could you help to take a look at it? If we missed something, please let us know. Thanks.

https://github.com/user-attachments/assets/4a75d594-17de-48b8-a142-75e0391687fb

yanghhhhhhh avatar Sep 11 '25 08:09 yanghhhhhhh

Hi @SaladinAyyub , thank you for reporting this issue. We tried to check this issue in Visual Studio Code v1.103.2 + CMake Tools v1.21.36. We can switch between Debug and Release configurations. Could you help to take a look at it? If we missed something, please let us know. Thanks.

Repro4569.webm

Ok 3 issues or suggestions that I would like to point out, don't know how the team feels about it ->

  1. The QuickStart only generates the debug profile, I think it would be better to generate atleast the release profile in the preset.

  2. the display name for the default preset is simply "displayName": "GCC 14.3.0 x86_64-unknown-linux-gnu" because it asks for the default preset name in the QuickStart it should probably do something like "displayName": "GCC 14.3.0 x86_64-unknown-linux-gnu-$WHATEVER_THE_USER_NAMED_THE_PRESET" or simply make the default to be "displayName": "GCC 14.3.0 x86_64-unknown-linux-gnu-Debug". This maybe distro specfic issue but most probably not.

  3. I think QuickStart should also match the behavior of the set mode. For example there is a mismatch. By default it uses the variants method but it generates the preset method. I think both should be identical by default. Maybe "cmake.useCmakePresets": "always" can be made the default or detect it automatically so if the variant file is present it uses the variant mode. Otherwise some new user who may be doing QuickStart will have to deal with the mismatch.

I think I also got confused because of the display name. I didn't notice it. Anyway this issue can be closed. Also the Docs show the variant way of doing things after the quickstart

https://code.visualstudio.com/docs/cpp/cmake-linux

So this also has the same mismatch, that I told in point 3. Maybe a seperate issue can be created for this. Thanks for the response brother !

Saladin1812 avatar Sep 11 '25 13:09 Saladin1812

@SaladinAyyub Thank you for your detailed information. We consider these 3 issues to be suggestions. Do you agree? If so, we will add the feature tag "enhancement" to this issue and remove the "bug" tag. Thank you.

yanghhhhhhh avatar Sep 12 '25 09:09 yanghhhhhhh

@SaladinAyyub Thank you for your detailed information. We consider these 3 issues to be suggestions. Do you agree? If so, we will add the feature tag "enhancement" to this issue and remove the "bug" tag. Thank you.

Sure.. but the 3rd one can be considered a bug.. or atleast how it is percieved from the docs.. but sure.. you can add the feature tag emhancement and remove the bug tag.

Saladin1812 avatar Sep 12 '25 16:09 Saladin1812

@SaladinAyyub Thank you for your reply. Could you create a new issue to track the 3rd issue and provide the detailed repro steps , expected results, and actual results so we can investigate this further? We will continue to look into it. Thank you.

yanghhhhhhh avatar Sep 15 '25 08:09 yanghhhhhhh