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
Incorrect schema version constraint applied to CMakeUserPresets.json #2897
Comments
using |
I can confirm that CMake does accept it. Here are some minimal files that you can use. I confirmed that CMakePresets.json{
"version": 3,
"configurePresets": [
{
"name": "default",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build",
"toolchainFile": "${sourceDir}/toolchain.cmake"
}
]
} CMakeUserPresets.json{
"version": 2,
"configurePresets": [
{
"name": "my_thing",
"inherits": "default"
}
]
} CMakeLists.txtcmake_minimum_required(VERSION 3.21)
project(vscode_bug_2897 LANGUAGES NONE)
With the above minimal set of files,
If I try to get vscode to open the folder, it fails with the following message in the "CMake/Build" output panel:
|
I could repro this issue. It looks like CMake allows this setting. We check for version compatibility after expanding the preset, maybe we should check them before expansion: vscode-cmake-tools/src/preset.ts Lines 702 to 706 in 9e4fdd5
|
Brief Issue Summary
If a user preset defined in
CMakeUserPresets.json
inherits from a base preset defined inCMakePresets.json
, VS Code incorrectly requires theversion
field inCMakeUserPresets.json
to be no older than the version needed for the base preset.To reproduce the bug:
CMakePresets.json
, setversion
to 3.CMakePresets.json
, define a configure preset and add thetoolchainFile
field (this requires schema version 3 or later).CMakeUserPresets.json
, setversion
to 2.CMakeUserPresets.json
, define a configure preset that inherits from the one defined above. Don't add anything to this new configure preset, it just needs to inherit from the other one.CMake itself accepts the above arrangement, which you can verify using
cmake --list-presets
. However, VS Code complains that thetoolchainFile
field requires version 3 and refuses to accept it. But that version constraint is satisfied in the context wheretoolchainFile
is used (CMakePresets.json
). TheCMakeUserPresets.json
file is not required to also be version 3 in order to inherit the base preset which does use something from a version 3 schema.Potentially related: https://gitlab.kitware.com/cmake/cmake/-/issues/22428
CMake Tools Diagnostics
No response
Debug Log
No response
Additional Information
No response
The text was updated successfully, but these errors were encountered: