Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use of field condition in CMake Presets v3 is bugged #2185

Closed
vdilecce opened this issue Oct 16, 2021 · 2 comments
Closed

Use of field condition in CMake Presets v3 is bugged #2185

vdilecce opened this issue Oct 16, 2021 · 2 comments
Labels
bug a bug in the product Feature: presets
Milestone

Comments

@vdilecce
Copy link

Brief Issue Summary

When the field condition is used in a CMake preset, the extension CMake Tools shows a bugged behavior.

Consider the following CMakePresets.json defining two configure presets (Visual Studio 2017 on Windows and Ninja Multi-Config on Linux) with the relative build preset combinations:

{
  "version": 3,
  "cmakeMinimumRequired": {
    "major": 3,
    "minor": 21,
    "patch": 0
  },
  "configurePresets": [
    {
      "name": "windows-base",
      "hidden": true,
      "condition": {
        "type": "equals",
        "lhs": "${hostSystemName}",
        "rhs": "Windows"
      }
    },
    {
      "name": "linux-base",
      "hidden": true,
      "condition": {
        "type": "equals",
        "lhs": "${hostSystemName}",
        "rhs": "Linux"
      }
    },
    {
      "name": "multi-config-base",
      "binaryDir": "buildc",
      "hidden": true
    },
    {
      "name": "vs-base",
      "hidden": true,
      "architecture": {
        "value": "x64",
        "strategy": "set"
      },
      "toolset": {
        "value": "host=x64",
        "strategy": "set"
      }
    },
    {
      "name": "vs2017",
      "inherits": [
        "windows-base",
        "vs-base",
        "multi-config-base"
      ],
      "displayName": "Visual Studio 2017",
      "description": "Architecture x64 - Toolset v141",
      "generator": "Visual Studio 15 2017"
    },
    {
      "name": "ninja-multi-config",
      "generator": "Ninja Multi-Config",
      "displayName": "Ninja",
      "description": "Multi-Config",
      "inherits": [
        "linux-base",
        "multi-config-base"
      ]
    }
  ],
  "buildPresets": [
    {
      "name": "windows-base",
      "hidden": true,
      "condition": {
        "type": "equals",
        "lhs": "${hostSystemName}",
        "rhs": "Windows"
      }
    },
    {
      "name": "linux-base",
      "hidden": true,
      "condition": {
        "type": "equals",
        "lhs": "${hostSystemName}",
        "rhs": "Linux"
      }
    },
    {
      "name": "vs2017-base",
      "configurePreset": "vs2017",
      "hidden": true
    },
    {
      "name": "ninja-multi-config-base",
      "configurePreset": "ninja-multi-config",
      "hidden": true
    },
    {
      "name": "debug-base",
      "configuration": "Debug",
      "hidden": true
    },
    {
      "name": "release-base",
      "configuration": "Release",
      "hidden": true
    },
    {
      "name": "relwithdebinfo-base",
      "configuration": "RelWithDebInfo",
      "hidden": true
    },
    {
      "name": "minsizerel-base",
      "configuration": "MinSizeRel",
      "hidden": true
    },
    {
      "name": "vs2017-debug",
      "displayName": "Debug",
      "inherits": [
        "windows-base",
        "vs2017-base",
        "debug-base"
      ]
    },
    {
      "name": "vs2017-release",
      "displayName": "Release",
      "inherits": [
        "windows-base",
        "vs2017-base",
        "release-base"
      ]
    },
    {
      "name": "vs2017-relwithdebinfo",
      "displayName": "RelWithDebInfo",
      "inherits": [
        "windows-base",
        "vs2017-base",
        "relwithdebinfo-base"
      ]
    },
    {
      "name": "vs2017-minsizerel",
      "displayName": "MinSizeRel",
      "inherits": [
        "windows-base",
        "vs2017-base",
        "minsizerel-base"
      ]
    },
    {
      "name": "ninja-multi-config-debug",
      "displayName": "Debug",
      "inherits": [
        "linux-base",
        "ninja-multi-config-base",
        "debug-base"
      ]
    },
    {
      "name": "ninja-multi-config-release",
      "displayName": "Release",
      "inherits": [
        "linux-base",
        "ninja-multi-config-base",
        "release-base"
      ]
    },
    {
      "name": "ninja-multi-config-relwithdebinfo",
      "displayName": "RelWithDebInfo",
      "inherits": [
        "linux-base",
        "ninja-multi-config-base",
        "relwithdebinfo-base"
      ]
    }
  ]
}

Expected behavior:

  • Only presets matching the condition are visible in the list presented when the button for selecting the presets in the side bar is clicked.
  • All presets matching the condition are always visible every time the button for selecting the presets in the side bar is clicked.

Actual behavior:

  • All presets are visible.
  • Once a preset is selected, it is no more presented in list shown when the button for selecting the presets in the side bar is clicked. Only restarting Visual Studio Code resets the behavior.

If the condition field is removed form the CMakePresets.json, everything works as expected.

Platform and Versions

  • Operating System: Windows 10
  • CMake Version: 3.21.3
  • VSCode Version: 1.61.1
  • CMake Tools Extension Version: 1.9.0
  • C/C++ Extension Version: 1.7.0
  • Compiler/Toolchain: Visual Studio 2017
@bobbrow bobbrow added bug a bug in the product Feature: presets labels Oct 19, 2021
@bobbrow bobbrow added this to the On Deck milestone Oct 19, 2021
@bobbrow
Copy link
Member

bobbrow commented Oct 19, 2021

Thanks for reporting this. There's definitely some problems here. Thank you for sharing your presets. I am testing a fix.

@andreeis
Copy link
Contributor

@vdilecce, a fix for this problem was included in the CMake Tools 1.9.1 release. Upgrade your extension in VSCode and let us know if you encounter any other issues.

@github-actions github-actions bot locked and limited conversation to collaborators Jan 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug a bug in the product Feature: presets
Projects
None yet
Development

No branches or pull requests

3 participants