microsoft / vscode-cmake-tools

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

CMakeUserPresets.json - not parsed anymore in v1.19.46 #4011

Closed dornbirndevelops closed 2 months ago

dornbirndevelops commented 2 months ago

Brief Issue Summary

A completely valid CMakeUserPresets.json cannot be parsed with the currently latest pre-release.

Consider the following CMake presets configuration for the steps below:

{
    "version": 4,
    "configurePresets": [
        {
            "name": "default",
            "hidden": false,
            "description": "Default configuration",
            "generator": "Ninja",
            "binaryDir": "${sourceDir}/build",
            "cacheVariables": {
                "CMAKE_BUILD_TYPE": "Release",
                "CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
                "CMAKE_INSTALL_PREFIX": "${sourceDir}/install"
            }
        }
    ],
    "buildPresets": [
        {
            "name": "default",
            "hidden": false,
            "description": "Default build",
            "configurePreset": "default",
            "targets": [
                "all"
            ]
        }
    ]
}

Create a CMakePresets.json file with the content from before. Run the CMake: Select Configure Preset command. Observation: Configure Preset from file is shown as expected

Now, rename the CMakePresets.json file to a CMakeUserPresets.json file. Run the CMake: Select Configure Preset command. Observation: Configure Preset from file is not shown anymore. Additionally, the editor highlights an error in line 1 "Could not find configure preset 'default' in preset 'default'".

CMake Tools Diagnostics

{
  "os": "linux",
  "vscodeVersion": "1.92.2",
  "cmtVersion": "1.19.46",
  "configurations": [
    {
      "folder": "/workspaces/my_ide",
      "cmakeVersion": "3.30.2",
      "configured": false,
      "generator": "",
      "usesPresets": true,
      "compilers": {}
    },
    {
      "folder": "/workspaces/my_ide/repos/ccc_demo_lib",
      "cmakeVersion": "3.30.2",
      "configured": false,
      "generator": "",
      "usesPresets": true,
      "compilers": {}
    },
    {
      "folder": "/home/user/.conan",
      "cmakeVersion": "3.30.2",
      "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": "always",
      "configureOnOpen": false
    },
    {
      "communicationMode": "automatic",
      "useCMakePresets": "always",
      "configureOnOpen": false
    },
    {
      "communicationMode": "automatic",
      "useCMakePresets": "always",
      "configureOnOpen": false
    }
  ]
}

Debug Log

[proc] Executing command: /usr/local/bin/cmake --version
[proc] Executing command: /usr/local/bin/cmake -E capabilities
[main] Safe constructing new CMakeProject instance
[variant] Constructing VariantManager
[main] Constructing new CMakeProject instance
[main] Starting CMake Tools second-phase init
[expand] expanded ${workspaceFolder}
[kit] Not reading non-existent kits file: /home/user/.local/share/CMakeTools/cmake-tools-kits.json
[kit] Not reading non-existent kits file: /workspaces/my_ide/.vscode/cmake-kits.json
[main] CMakeProject instance initialization complete.
[main] Safe constructing new CMakeProject instance
[variant] Constructing VariantManager
[main] Constructing new CMakeProject instance
[main] Starting CMake Tools second-phase init
[expand] expanded ${workspaceFolder}
[kit] Not reading non-existent kits file: /home/user/.local/share/CMakeTools/cmake-tools-kits.json
[kit] Not reading non-existent kits file: /workspaces/my_ide/repos/ccc_demo_lib/.vscode/cmake-kits.json
[presetController] Reading presets file /workspaces/my_ide/repos/ccc_demo_lib/CMakeUserPresets.json
[presetController] Reading and validating the presets "file /workspaces/my_ide/repos/ccc_demo_lib/CMakeUserPresets.json"
[presetController] Successfully validated /workspaces/my_ide/repos/ccc_demo_lib/CMakeUserPresets.json against presets schema
[presetController] Reading presets file /workspaces/my_ide/repos/ccc_demo_lib/build/x86_64-gcc-debug/generators/CMakePresets.json
[presetController] Reading and validating the presets "file /workspaces/my_ide/repos/ccc_demo_lib/build/x86_64-gcc-debug/generators/CMakePresets.json"
[presetController] Successfully validated /workspaces/my_ide/repos/ccc_demo_lib/build/x86_64-gcc-debug/generators/CMakePresets.json against presets schema
[presetController] Expanding presets file /workspaces/my_ide/repos/ccc_demo_lib/CMakeUserPresets.json
[proc] Executing command: uname -s
[preset] Could not find configure preset with name x86_64-gcc-debug
[preset] Could not find configure preset with name x86_64-gcc-debug
[presetController] Expansion errors found in the presets file.
[main] CMakeProject instance initialization complete.
[main] Safe constructing new CMakeProject instance
[variant] Constructing VariantManager
[main] Constructing new CMakeProject instance
[main] Starting CMake Tools second-phase init
[expand] expanded ${workspaceFolder}
[kit] Not reading non-existent kits file: /home/user/.local/share/CMakeTools/cmake-tools-kits.json
[kit] Not reading non-existent kits file: /home/user/.conan/.vscode/cmake-kits.json
[main] CMakeProject instance initialization complete.
[extension] Attempting to use cache to configure workspace file:///workspaces/my_ide/repos/ccc_demo_lib
[main] Starting new CMake driver
[main] Starting CMake driver
[cmakefileapi-driver] Creating instance of CMakeFileApiDriver
[driver] Initializing base driver using preset
[main] Unable to configure with existing cache
[extension] [4027] 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] [4027] cmake.selectConfigurePreset finished (returned false)

Additional Information

BEFORE: content of CMakeUserPresets.json gets recognized and parsed in v1.18.44 when reloading the window.

image


AFTER: content of CMakeUserPresets.json is not recognized and therefore not parsed in v1.19.46 when reloading the window.

image

gcampbell-msft commented 2 months ago

@dornbirndevelops Thanks for the issue! We will have this fixed shortly, as we are in the process of releasing our 1.19 official version in the coming week or so. It will get fixed hopefully in the next couple days in pre-release, and then the official release behind it, if everything goes to plan 👍

Thanks for helping us by using pre-release!

v-frankwang commented 2 months ago

We verified this issue on CMake Tools: v1.19.47 (pre-release) and it has been fixed: image

dornbirndevelops commented 2 months ago

Thank you very much @gcampbell-msft ! I verified the current state of main, including the changes from https://github.com/microsoft/vscode-cmake-tools/pull/4008. They also fixed my original problems in https://github.com/microsoft/vscode-cmake-tools/issues/3974. Looking forward to the next extension release 🎉

FTR: cmake.configureOnEdit does not have to be set to true.