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

CMakePresets.json schema is too restrictive #1963

Closed
KUGA2 opened this issue Jun 29, 2021 · 6 comments · Fixed by #2945
Closed

CMakePresets.json schema is too restrictive #1963

KUGA2 opened this issue Jun 29, 2021 · 6 comments · Fixed by #2945
Labels
bug a bug in the product Feature: presets
Milestone

Comments

@KUGA2
Copy link

KUGA2 commented Jun 29, 2021

Brief Issue Summary

I cannot add the new CMake 3.21 feature "conditions" to the CMakePresets.json without breaking cmake-tools. Or any other feature that might come.

The plugin validates the CMakePresets.json and does not load it.
The same issue was seen here #1934, but this Issue is for a more general issue.

Apparent Behaviour

Tooltip:
image

And no preset found:
image

Code:

        {
            "name": "x86_64-windows-user-vs2019-Release",
            ...
            "condition": {
                "type": "equals",
                "lhs": "$env{VSCMD_ARG_TGT_ARCH}",
                "rhs": "x64"
            }
        },

Expected:

It should leave the validation to cmake.exe. e.g. you could run cmake --list-presets and then offer those shown (this will also implicitly enable the condition feature).

$ set | grep VSCMD_ARG_TGT_ARCH
VSCMD_ARG_TGT_ARCH=x86

$ cmake --list-presets
Available configure presets:

  "x86-windows-user-vs2019-Release"

CMake Tools Log

[presetController] Invalid kit contents CMakePresets.json (d:\git\xx\CMakePresets.json):
[presetController]  >> /configurePresets/1: should NOT have additional properties
[presetController]  >> /configurePresets/2: should NOT have additional properties

Platform and Versions

  • Operating System: Windows
  • CMake Version: 3.21.0-rc1
  • VSCode Version: 1.57.1
  • CMake Tools Extension Version: private build. see Existing presets are not shown #1934
  • Compiler/Toolchain: VS2019
@bobbrow
Copy link
Member

bobbrow commented Jun 30, 2021

It looks like we are going to need to make the schema check optional when the presets file version is higher than what we support. Thanks for reporting this!

@bobbrow bobbrow added this to the 1.8.0 milestone Jun 30, 2021
@bobbrow bobbrow added bug a bug in the product Feature: presets labels Jun 30, 2021
@KUGA2
Copy link
Author

KUGA2 commented Jul 1, 2021

Hi @bobbrow, why validate it at all? Just run cmake --list-presets and display those presets. Leave the verfication to cmake executable.

@bobbrow
Copy link
Member

bobbrow commented Jul 1, 2021

Kitware's recommendation to IDEs is to get the information out of the presets file and invoke the CLI with those parameters instead of using --preset. That's perhaps a discussion we need to revisit. The other benefit of schema validation is that we can provide IntelliSense help when making changes to the file. But if the schema is unstable because Kitware is adding stuff to it every release, we are going to have problems with that.

@bobbrow
Copy link
Member

bobbrow commented Jul 1, 2021

Tagging: @esweet431

@KUGA2
Copy link
Author

KUGA2 commented Jul 5, 2021

Kitware's recommendation to IDEs is to get the information out of the presets file and invoke the CLI with those parameters instead of using --preset.

I have also seen this recommendation but cannot find it anymore. Maybe they removed it? Can you link it?

@esweet431
Copy link
Contributor

The recommendation is part of the IDE integration guide: https://cmake.org/cmake/help/latest/guide/ide-integration/index.html#presets

@bobbrow bobbrow changed the title CMakePresets.json schema is to restrictive CMakePresets.json schema is too restrictive Jul 30, 2021
@bobbrow bobbrow modified the milestones: 1.8.0, 1.9.0 Aug 17, 2021
@bobbrow bobbrow modified the milestones: 1.9.0, On Deck Oct 15, 2021
@bobbrow bobbrow modified the milestones: On Deck, 1.13 Jan 13, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Feb 28, 2023
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
3 participants