in CMakePresets.json, allow trailing commas

in CMakePresets.json, comments are currently allowed.

Please relax the parser to allow trailing commas.

cmake --list-presets
CMake Error: Could not read presets from /workspaces/nf-interpreter: JSON parse error

This has been discussed before. The file uses JSON and JSON does not support trailing commas or comments. Adding extensions (even common ones) just makes it less likely that tooling supports the preset files.

Cc: @kyle.edwards

Thanks for your reply and consideration… Please consider:
a) I tested before posting… CMake already allows comments in the file,
b) trailing commas are becoming much more popular over the last years with many more tools supporting.

If we still choose to not support commas, please consider improve the error message to include the JSON Parser error location. It currently does not list the offending file or location.

Hmm. I thought we discussed comments and turned that off. And yes, I had misread it as “disallowed” or something, sorry.

Which CMake version are you using? I think there was a period where it may have worked, but like Ben mentioned, I too thought that comments are now explicitly rejected. I don’t know which release that may have occurred in, but if you test with the latest release, I would expect comments to be rejected.

As a comment more generally, formally CMake only supports a presets file that follows the official JSON spec and the presets schema that is part of CMake. That in turn means that any other consumer of CMake presets files only has to support those things too. Remember that the implications for what CMake supports can be far-reaching, since it will propagate out to things like every IDE implementation that supports CMake presets, tooling that might read and use the presets, and so on. On that basis, comments and trailing commas do not meet the spec and are not supported.

ok, please consider improving error reporting. the project I am working on (.Net nanoFramework) has a root CMakePresets.json with at least 2 level of further imported files for various targets (about 20 files in total). The undetailed error message can make find the offending file very time consuming.

cmake --version
cmake version 3.24.0

with content:
// comment test
“version”: 4,
“include”: [

cmake --list-presets
Available configure presets:


I see that version 3.24.0 is about a year old now. I will submit Pull Request to the project to update their devcontainer definitions which are calling that version out explicitly.


I rebuilt my local devcontainer with CMake 3.27.6.

comments do not cause an error in cmake --list-presets, but DO error when configure is running…

[presetController] Failed to parse CMakePresets.json:

SyntaxError: Unexpected token / in JSON at position 7

at JSON.parse ()

at PresetsController.parsePresetsFile (/root/.vscode-server/extensions/ms-vscode.cmake-tools-1.15.31/dist/main.js:51003:36)

at PresetsController.resetPresetsFile (/root/.vscode-server/extensions/ms-vscode.cmake-tools-1.15.31/dist/main.js:50259:38)

at async PresetsController.reapplyPresets (/root/.vscode-server/extensions/ms-vscode.cmake-tools-1.15.31/dist/main.js:50278:9)

[preset] Could not find configure preset with name RP2040

[main] Failed to resolve configure preset: RP2040

The errors look to me like they were coming directly from VS Code, not from CMake.
I guess VS Code tries to parse the presets as JSON, and fails.

Cc: @kyle.edwards Looks like comments are allowed in presets in some codepaths?