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 should allow JSON comments #2104

Closed
tilman22 opened this issue Sep 2, 2021 · 8 comments
Closed

CMakePresets.json should allow JSON comments #2104

tilman22 opened this issue Sep 2, 2021 · 8 comments
Labels
Feature: presets upstream Bugs related to issues in an upstream project

Comments

@tilman22
Copy link

tilman22 commented Sep 2, 2021

cmake allows the CMakePresets.json file to contain JSON-comments.
But the cmake-extension complains if there are comments:

[presetController] Failed to parse CMakePresets.json:
SyntaxError: Unexpected token / in JSON at position 461
at JSON.parse ()
at PresetsController.parsePresetsFile (/home/soti/.vscode-server/extensions/ms-vscode.cmake-tools-1.8.0/dist/main.js:57650:32)
at PresetsController.resetPresetsFile (/home/soti/.vscode-server/extensions/ms-vscode.cmake-tools-1.8.0/dist/main.js:57036:38)
at async PresetsController.reapplyPresets (/home/soti/.vscode-server/extensions/ms-vscode.cmake-tools-1.8.0/dist/main.js:57051:9)
at async FSWatcher. (/home/soti/.vscode-server/extensions/ms-vscode.cmake-tools-1.8.0/dist/main.js:56993:17)
[preset] Could not find configure preset with name

@bobbrow
Copy link
Member

bobbrow commented Sep 2, 2021

Is that new? Because we just addressed an issue where someone said cmake doesn't support JSON 5. See #2035

@tilman22
Copy link
Author

tilman22 commented Sep 3, 2021

I'm using cmake 3.20. By trying out, I observed that cmake supports comments in CMakePrefixs.json (i.e. by using "cmake --prefix ...").
The problem which I reported above seems to be an issue of the cmake extension.
I haven't observed this error messages before (with older previous of the cmake extensions).

[Remark: The cmake Extension is just great! Thanks a lot for your work on the extension!!!]

@bobbrow
Copy link
Member

bobbrow commented Sep 3, 2021

@xisui-MSFT When you fixed #2035, what were your observations?

@xisui-MSFT
Copy link
Collaborator

xisui-MSFT commented Sep 3, 2021

The extension should force presets files to use json format (as opposed to jsonc) whenever a presets file is opened or activated, and you even shouldn't be able to set it to jsonc manually... But I'm wondering if this is caused by a conflict with @tilman22 's settings or another extension.

@bobbrow
Copy link
Member

bobbrow commented Sep 3, 2021

I don't think it's settings. He is reporting that passing in a preset on the command line works when the CMakePresets file has comments in it. Do you see the same or different result?

@xisui-MSFT
Copy link
Collaborator

Ah sorry I misunderstood. That's a good question. We should ask kitware as it's explicitly disallowed in the doc: https://cmake.org/cmake/help/latest/release/3.19.html#id6.

@bobbrow
Copy link
Member

bobbrow commented Sep 3, 2021

I can confirm that comments work with the presets file in 3.20.2 and 3.21.2. Seems like a bug on Kitware.

@bobbrow
Copy link
Member

bobbrow commented Sep 3, 2021

I opened this bug for them: https://gitlab.kitware.com/cmake/cmake/-/issues/22602

@bobbrow bobbrow added the upstream Bugs related to issues in an upstream project label Sep 3, 2021
@bobbrow bobbrow closed this as completed Sep 3, 2021
@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
Feature: presets upstream Bugs related to issues in an upstream project
Projects
None yet
Development

No branches or pull requests

3 participants