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

[Bug] condition in inherited build preset passes, but inherited build presets are not listed for selection

Open david-fong opened this issue 10 months ago • 7 comments

Brief Issue Summary

I'm using CMake v4.0. I can repro with my emscripten presets in https://github.com/david-fong/okiidoku/commit/399fcdb94525e690f35baaf270ae670ef3985529. I can't work up the motivation to make a minimal repro right now- apologies. Relevant snippets from my preset file:

		{
			"name": "tool:emscripten",
			"hidden": true,
			"description": "available if you set/export EMSDK environment variable. good for IDEs which are hard to configure to use `emcmake cmake`.",
			"condition": {"type": "notEquals", "lhs": "$env{EMSDK}", "rhs": ""},
			"toolchainFile": "$env{EMSDK}/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake",
			"cacheVariables": {
				"CMAKE_CONFIGURATION_TYPES": "MinSizeRel;Debug;Release",
				"OKIIDOKU_BUILD_BINDINGS_FOR_PYTHON": null
			}
		},
//...
		{
			"name": "base:dev.emscripten",
			"hidden": true,
			"condition": {"type": "notEquals", "lhs": "$env{EMSDK}", "rhs": ""},
			"targets": ["all"]
		},
		{
			"name": "dev.emscripten.debug",
			"configurePreset": "dev.emscripten",
			"displayName": "debug",
			"inherits": ["base:dev.emscripten"],
			"configuration": "Debug"
		},

cmake --build --list-presets works as expected though.

CMake Tools Diagnostics

{
  "os": "linux",
  "vscodeVersion": "1.99.3",
  "cmtVersion": "1.21.17",
  "configurations": [
    {
      "folder": "/home/.../ok",
      "cmakeVersion": "4.0.1",
      "configured": true,
      "generator": "Ninja Multi-Config",
      "usesPresets": true,
      "compilers": {}
    }
  ],
  "cpptoolsIntegration": {
    "isReady": true,
    "hasCodeModel": true,
    "activeBuildType": "MinSizeRel",
    "buildTypesSeen": [
      "MinSizeRel",
      "Debug",
      "Release"
    ],
    "requests": [],
    "responses": [],
    "partialMatches": [],
    "targetCount": 5,
    "executablesCount": 3,
    "librariesCount": 2,
    "targets": [
      {
        "name": "okiidoku",
        "type": "STATIC_LIBRARY"
      },
      {
        "name": "okiidoku_cli",
        "type": "EXECUTABLE"
      },
      {
        "name": "okiidoku_cli_utils",
        "type": "STATIC_LIBRARY"
      },
      {
        "name": "okiidoku_js",
        "type": "EXECUTABLE"
      },
      {
        "name": "okiidoku_translator",
        "type": "EXECUTABLE"
      }
    ]
  },
  "settings": [
    {
      "communicationMode": "automatic",
      "useCMakePresets": "always",
      "configureOnOpen": false
    }
  ]
}

Debug Log

[presetController] Successfully expanded presets file /home/.../ok/cpp/CMakePresets.json
[driver] Switching to configure preset: dev.emscripten
[driver] Switching to build preset: __defaultBuildPreset__
[driver] Switching to test preset: __defaultTestPreset__
[driver] Switching to package preset: dev.emscripten.release
[driver] Switching to workflow preset: __defaultWorkflowPreset__
[extension] [1900] cmake.buildDirectory started
[extension] [1900] cmake.buildDirectory finished (returned "/home/.../ok/cpp/out/build/dev.emscripten")
[extension] [6898] cmake.selectBuildPreset started
[presetController] Start selection of build presets. Found 4 presets.
[presetController] Opening build preset selection QuickPick
[presetController] User cancelled build preset selection
[extension] [6898] cmake.selectBuildPreset finished (returned false)


It says it found 4, but only shows "\[Default\]" and "Add new preset".

Additional Information

I'm surprised CMake's file api doesn't seem to have much to support tools in implementing preset support.

david-fong avatar Apr 23 '25 02:04 david-fong

Hi @david-fong, thanks for reporting issue here!

I have created a minimal repro project and reproduced issue on CMake Tools latest v1.21.8(pre-release), it only shows "[Default]" and "Add new preset" when I select Build preset, but the build preset list when running cmake --build --list-presets in terminal.

demo_project.zip

Image

@gcampbell-msft FYI.

Amy-Li03 avatar Apr 24 '25 07:04 Amy-Li03

I've reproduced and marked it as a bug to fix for the next release. Thanks

gcampbell-msft avatar Apr 25 '25 15:04 gcampbell-msft

Verified this on CMake Tools v1.21.23(pre-release), issue was fixed. Now the inherited build presets are listed for selection.

Image

Amy-Li03 avatar May 13 '25 07:05 Amy-Li03

Now it doesn't even list my conditional configure preset for selection... v1.22.9

david-fong avatar Sep 19 '25 05:09 david-fong

@david-fong Thank you for reporting this issue. We have verified this issue using this sample project(demo_project.zip) in VS Code 1.104.1 + CMake tools 1.22.9 and we can reproduce it. So we reopen this issue. Thank you.

https://github.com/user-attachments/assets/95179547-ef9a-4319-9923-0b621fbdf1f9

FYI: @gcampbell-msft

yanghhhhhhh avatar Sep 22 '25 07:09 yanghhhhhhh

I didn’t mean to send the above message :P I think the issue I was having a few days ago was related to VS Code’s shell startup file behaviour(?). I’m honestly not sure. But if you can reproduce the issue then maybe it’s still a CMake Tools bug.

david-fong avatar Sep 22 '25 11:09 david-fong

@david-fong Thank you for your information. Please continue to follow up on this issue. Thank you.

yanghhhhhhh avatar Sep 23 '25 01:09 yanghhhhhhh