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

[Bug] $comment in a preset is not accepted inside a cacheVariable

Open cmorve-te opened this issue 2 months ago • 1 comments

Brief Issue Summary

While

            "cacheVariables": {
                "$comment": "My comment",
                "CMAKE_EXE_LINKER_FLAGS": {
                    "type": "STRING",
                    "value": "-Wno-error=free-nonheap-object"
                }
            }

is accepted,

            "cacheVariables": {
                "CMAKE_EXE_LINKER_FLAGS": {
                    "type": "STRING",
                    "$comment": "My comment",
                    "value": "-Wno-error=free-nonheap-object"
                }
            }

is not.

CMake itself does accept the "$comment" in there, with the documentation saying

Preset files specifying version 10 or above may include comments using the key $comment at any level within the JSON object to provide documentation.

CMake Tools Diagnostics

Not needed.

Debug Log

Not needed.

Additional Information

No response

cmorve-te avatar Oct 21 '25 19:10 cmorve-te

Hi @cmorve-te, thanks for reporting issue here! We can reproduce this issue on VS Code 1.105.1 + CMake tools 1.21.36 version. Repro Steps:

  1. Create a new folder and quick start a new CMake project .
  2. Open CMakePresets.json, add the following code.
"CMAKE_EXE_LINKER_FLAGS": {
      "type": "STRING",
      "$comment": "My comment",
      "value": "-Wno-error=free-nonheap-object"
 },
  1. Observe the result.

Details please see following video:

Image

@gcampbell-msft

yanghhhhhhh avatar Oct 22 '25 03:10 yanghhhhhhh