microsoft / microsoft/vscode-cmake-tools
cmake-presets attribute toolset gets ignored when generator attribute is empty
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.7k
- Forks
- 546
- Avg merge
- 2d 16h
- Merged PRs (30d)
- 32
Description
### Brief Issue Summary
In our project we are using Visual Studio generators in order to generate cmake project with VS2017 compilers (V141 toolset). In other words, across the team we have different versions of Visual Studio ranging from 2017 to 2022 with only one common denominator and that is target Visual C++ toolset. In our case it is V141 which are VS2017 compilers. So users normally generate their solutions by omitting -G flag and just providing -T v141 and -A x64 flags. Cmake will handle the rest and find compatible Visual Studio.
Now I have a configure-presets that inherit this:
```
{
"name": "MSVC_x64",
"hidden": true,
"description": "Default MSVC 141 x64 preset",
"toolset": {
"value": "v141",
"strategy": "set"
},
"architecture": "x64"
}
```
This works great when cmake configure is executed from console (cmd.exe). CMake correctly identifies that my generator is VS2022 since its the only Visual Studio I have installed on my PC. I can see from cmake logs that proper version of C/C++ compilers is selected (V141 toolset).
Now when I configure the same preset from VSCode via cmake tools extension, no matter what always the latest C/C++ compilers are taken from VS2022 (V143 toolset). Even if I put some random string garbage for toolset value, cmake cmake tools would still configure with VS2022 compilers.
Only if I provide specific generator to CMakePresets.json file, in my case "Visual Studio 17 2022", toolset attribute starts working and cmake project with correct compilers gets generated. This looks like a bug to me since cmake itself can handle that by no issue. Or am I missing something?
### CMake Tools Diagnostics
```
{
"os": "win32",
"vscodeVersion": "1.95.1",
"cmtVersion": "1.19.52",
"configurations": [
{
"folder": "d:\\eSmart\\_P-eSmart\\trunk",
"cmakeVersion": "3.30.3",
"configured": true,
"generator": "",
"usesPresets": true,
"compilers": {}
}
],
"cpptoolsIntegration": {
"isReady": true,
"hasCodeModel": true,
"activeBuildType": "Debug",
"buildTypesSeen": [
"Debug",
"Release",
"MinSizeRel",
"RelWithDebInfo"
],
"requests": [],
"responses": [],
"partialMatches": [],
"targetCount": 632,
"executablesCount": 91,
"librariesCount": 220,
"targets": []
},
"settings": [
{
"communicationMode": "automatic",
"useCMakePresets": "auto",
"configureOnOpen": false
}
]
}
```
### Debug Log
_No response_
### Additional Information
_No response_
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
Start by reproducing the issue with the shown configure preset and the VS Code CMake Tools configuration, comparing it with command-line CMake using -T v141 and -A x64. Inspect how CMakePresets.json is handled when the generator is empty. Done means the preset's toolset is honored without specifying a generator, including detecting an invalid toolset value appropriately.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, typescript, vscode
- Domain
- build-system, developer-experience, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100