microsoft / vscode-cmake-tools

CMake integration in Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=vector-of-bool.cmake-tools
MIT License
1.43k stars 429 forks source link

Presets not working when using version 8 with $schema #3808

Closed mthierman closed 2 weeks ago

mthierman commented 3 weeks ago

Brief Issue Summary

Before version 8 presets were supported, the extension was probably ignoring the $schema property. Now when I set "$schema": "https://raw.githubusercontent.com/Kitware/CMake/master/Help/manual/presets/schema.json", the extension prints an error message and nothing populates in the presets dropdown.

[presetController] Unsupported presets detected in CMakePresets.json. Support is limited to features defined by version 8.
[presetController]  >> : should NOT have additional properties: $schema

Per the CMake documentation (https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html#format):

"$schema An optional string that provides a URI to the JSON schema that describes the structure of this JSON document. This field is used for validation and autocompletion in editors that support JSON schema. It doesn't affect the behavior of the document itself. If this field is not specified, the JSON document will still be valid, but tools that use JSON schema for validation and autocompletion may not function correctly. This is allowed in preset files specifying version 8 or above."

cmake.allowUnsupportedPresetsVersions no longer works, I have to delete the schema line from my preset JSON.

CMake Tools Diagnostics

{
  "os": "win32",
  "vscodeVersion": "1.89.1",
  "cmtVersion": "1.18.41",
  "configurations": [
    {
      "folder": "d:\\GitHub\\Glow",
      "cmakeVersion": "3.29.3",
      "configured": false,
      "generator": "",
      "usesPresets": true,
      "compilers": {}
    }
  ],
  "cpptoolsIntegration": {
    "isReady": false,
    "hasCodeModel": false,
    "activeBuildType": "",
    "buildTypesSeen": [],
    "requests": [],
    "responses": [],
    "partialMatches": [],
    "targetCount": 0,
    "executablesCount": 0,
    "librariesCount": 0,
    "targets": []
  },
  "settings": [
    {
      "communicationMode": "automatic",
      "useCMakePresets": "auto",
      "configureOnOpen": false
    }
  ]
}

Debug Log

[expand] expanding cmake
[proc] Executing command: "C:\Program Files\CMake\bin\cmake.EXE" --version
[proc] Executing command: "C:\Program Files\CMake\bin\cmake.EXE" -E capabilities
[main] Safe constructing new CMakeProject instance
[variant] Constructing VariantManager
[main] Constructing new CMakeProject instance
[main] Starting CMake Tools second-phase init
[expand] expanding ${workspaceFolder}
[variant] Loaded new set of variants
[rollbar] Unhandled exception: Unhandled Promise rejection: Reloading variants file d:\GitHub\Glow\.vscode Error: EISDIR: illegal operation on a directory, read {}
[rollbar] Unhandled exception: Unhandled Promise rejection: Reloading variants file d:\GitHub\Glow\.vscode Error: EISDIR: illegal operation on a directory, read {}
[kit] Reading kits file C:\Users\mthie\AppData\Local\CMakeTools\cmake-tools-kits.json
[kit] Successfully loaded 4 kits from C:\Users\mthie\AppData\Local\CMakeTools\cmake-tools-kits.json
[expand] expanding C:\Program Files\LLVM\bin\clang.exe
[expand] expanding C:\Program Files\LLVM\bin\clang++.exe
[expand] expanding C:\Program Files\LLVM\bin\clang-cl.exe
[expand] expanding C:\Program Files\LLVM\bin\clang-cl.exe
[expand] expanding C:\Programs\msys64\ucrt64\bin\gcc.exe
[expand] expanding C:\Programs\msys64\ucrt64\bin\g++.exe
[expand] expanding cmake
[kit] Not reading non-existent kits file: d:\GitHub\Glow\.vscode\cmake-kits.json
[expand] expanding D:/GitHub/Glow
[kit] Not reading non-existent kits file: d:\GitHub\Glow\.vscode\cmake-kits.json
[presetController] Reading presets file D:\GitHub\Glow\CMakePresets.json
[presetController] Reading and validating the presets "file D:\GitHub\Glow\CMakePresets.json"
[presetController] Unsupported presets detected in D:\GitHub\Glow\CMakePresets.json. Support is limited to features defined by version 8.
[presetController]  >> : should NOT have additional properties: $schema
[presetController] Unknown properties and macros can be ignored by using the 'cmake.allowUnsupportedPresetsVersions' setting.
[presetController] Reading presets file D:\GitHub\Glow\CMakeUserPresets.json
[presetController] Reading and validating the presets "file D:\GitHub\Glow\CMakeUserPresets.json"
[presetController] Unsupported presets detected in D:\GitHub\Glow\CMakeUserPresets.json. Support is limited to features defined by version 8.
[presetController]  >> : should NOT have additional properties: $schema
[presetController] Unknown properties and macros can be ignored by using the 'cmake.allowUnsupportedPresetsVersions' setting.
[main] CMakeProject instance initialization complete.
[extension] Attempting to use cache to configure workspace file:///d%3A/GitHub/Glow
[expand] expanding cmake
[extension] [1432] cmake.buildDirectory started
[main] Starting new CMake driver
[main] Starting CMake driver
[main] Using generator from user configuration: Ninja Multi-Config
[cmakefileapi-driver] Creating instance of CMakeFileApiDriver
[driver] Initializing base driver using preset
[expand] expanding D:/GitHub/Glow
[driver] Setting new variant Debug
[expand] expanding D:/GitHub/Glow
[main] Unable to configure with existing cache
[expand] expanding cmake
[extension] [1432] cmake.buildDirectory finished (returned null)
[extension] [1007] cmake.buildDirectory started
[expand] expanding cmake
[extension] [1007] cmake.buildDirectory finished (returned null)
[extension] [6109] cmake.selectConfigurePreset started
[presetController] Start selection of configure presets. Found 0 presets.
[presetController] Opening configure preset selection QuickPick
[presetController] User cancelled configure preset selection
[extension] [6109] cmake.selectConfigurePreset finished (returned false)

Additional Information

No response

gcampbell-msft commented 3 weeks ago

@mthierman I am working on a fix. However, our cmake.allowUnsupportedPresetsVersions setting is designed for schema versions that we don't yet support. Therefore, if you want to workaround this for now, while still adding the schema, you could set your schema version to 9 or above, which we don't support / have yet. This will all the cmake.allowUnsupportedPresetsVersions to take effect.

However, I am creating a PR now for the schema issue.