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 causes duplicate build preset entries #4104

Closed mthierman closed 1 month ago

mthierman commented 1 month ago

Brief Issue Summary

If CMakeUserPresets.json is present (and even if empty), build presets are duplicated. If CMakeUserPresets is deleted, the problem goes away.

CMake Tools Diagnostics

{
  "os": "win32",
  "vscodeVersion": "1.93.1",
  "cmtVersion": "1.19.52",
  "configurations": [
    {
      "folder": "d:\\Repos\\Glow",
      "cmakeVersion": "3.30.4",
      "configured": false,
      "generator": "Visual Studio 17 2022",
      "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

No response

Additional Information

Basic example preset files to reproduce issue:

CMakePresets.json:

{
    "$schema": "https://raw.githubusercontent.com/Kitware/CMake/master/Help/manual/presets/schema.json",
    "version": 9,
    "cmakeMinimumRequired": {
        "major": 3,
        "minor": 30,
        "patch": 0
    },
    "configurePresets": [
        {
            "name": "MSBuild",
            "generator": "Visual Studio 17 2022",
            "architecture": {
                "strategy": "set",
                "value": "x64"
            },
            "toolset": {
                "strategy": "set",
                "value": "host=x64"
            },
            "binaryDir": "${sourceDir}/build/Visual Studio 17 2022/MSVC"
        }
    ],
    "buildPresets": [
        {
            "name": "Debug",
            "configuration": "Debug",
            "configurePreset": "MSBuild"
        },
        {
            "name": "Release",
            "configuration": "Release",
            "configurePreset": "MSBuild"
        }
    ]
}

CMakeUserPresets.json

{
    "$schema": "https://raw.githubusercontent.com/Kitware/CMake/master/Help/manual/presets/schema.json",
    "version": 9,
    "cmakeMinimumRequired": {
        "major": 3,
        "minor": 30,
        "patch": 0
    }
}

This will cause Debug and Release build presets to show up twice in the dropdown selection list.