microsoft / microsoft/vscode-cmake-tools
Support alternate encodings of CMakePresets.json
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.7k
- Forks
- 546
- Avg merge
- 2d 16h
- Merged PRs (30d)
- 32
Description
I created a new cmake project using Visual Studio 2022 that targets both Windows and WSL-2.
Visual Studio 2022 generated a default CMakePresets.json file that contains default cmake presets for linux and Windows named linux-default and windows-default respectively.
Configuring and building the project works both via Visual Studio and via Visual Studio Command Prompt, for example:
cmake --preset=linux-default
However, when opening the same folder in Visual Studio Code, I can't view and choose one of the existing presets.
When I open the "Select Configure Preset" menu it is empty. I don't see any presets available. I only have an option to add a new preset.

Furthermore, if I try to add a new preset, it overrides the content of CMakePresets.json.
So how can I choose one of the pre existing presets? is this a bug?
UPDATE
It seems that somehow the json parser fails to work properly. This is what I see in the output window:
[presetController] Failed to parse CMakePresets.json:
SyntaxError: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at PresetsController.parsePresetsFile (c:\Users\mrmai\.vscode\extensions\ms-vscode.cmake-tools-1.9.2\dist\main.js:60445:36)
at PresetsController.resetPresetsFile (c:\Users\mrmai\.vscode\extensions\ms-vscode.cmake-tools-1.9.2\dist\main.js:59782:38)
at async PresetsController.reapplyPresets (c:\Users\mrmai\.vscode\extensions\ms-vscode.cmake-tools-1.9.2\dist\main.js:59797:9)
at async FSWatcher.<anonymous> (c:\Users\mrmai\.vscode\extensions\ms-vscode.cmake-tools-1.9.2\dist\main.js:59711:17)
It happens regardless of the actual content of the json file.
It seems the problem a problem with the file encoding. If I edit it with notepad++ and save it with utf-8 encoding, the parsing works. but if I slightly change it with VS Code the parsing error occurs.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce with a Visual Studio 2022-generated CMakePresets.json and inspect the presetController output, especially PresetsController.parsePresetsFile in the reported extension build. Verify that supported alternate encodings parse without the JSON error, preserve the file when edited in VS Code, and make the existing presets selectable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, typescript
- Domain
- build-system, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 40/100