Open m1lhaus opened 1 week ago
Hi @m1lhaus , thanks for reporting issue here! We try to reproduce your issue on our side with cmake tools extension v1.19.52 + cmake version 3.29.5-msvc4, however we get the same result when cmake configure is executed from console (cmd.exe) and from VSCode via cmake tools extension, C/C++ compilers are taken from VS2022 (V143 toolset). Please see the test result as below:
cmake configure is executed from console (cmd.exe)
cmake configure is executed from VSCode via cmake tools extension
As you said above, after added "generator": "Visual Studio 17 2022"
to CMakePresets.json file, C/C++ compilers are taken from V141 toolset.
Hello @Amy-Li03, well I get different result:
In both cases I am executing my only preset. See code snippet bellow. Also I am bit skeptical about how you are running it from the console. I can't see you explicitly calling a preset.
This would be a dummy preset I can share
{
"version": 9,
"cmakeMinimumRequired": {
"major": 3,
"minor": 30,
"patch": 0
},
"configurePresets": [
{
"name": "Base",
"hidden": true
},
{
"name": "MSVC_x64",
"hidden": true,
"description": "Default MSVC 141 x64 preset",
"toolset": {
"value": "v141",
"strategy": "set"
},
"architecture": "x64"
},
{
"name": "MQB_MEB",
"hidden": true,
"description": "Base MQB_MEB preset"
},
{
"name": "ALL",
"hidden": true,
"description": "Base ALL preset"
},
{
"name": "ALL_MQB_MEB",
"description": "Base ${presetName} preset",
"inherits": ["Base", "MSVC_x64", "ALL", "MQB_MEB"],
"binaryDir": "${sourceDir}/000_bin_preset/build"
}
]
}
Hi @m1lhaus , thanks for your quick response!
After using command: cmake --preset ALL_MQB_MEB
, C/C++ compilers are taken from V141 toolset when cmake configure is executed from console.
@gcampbell-msft I can repro customer's issue: when generator attribute is empty, C/C++ compilers are taken from V141 toolset when cmake configure is executed from console(cmake --preset ALL_MQB_MEB
), but they are taken from VS2022 (V143 toolset) when cmake configure is executed from VSCode via cmake tools extension.
I'm not sure if this is a feature request or a bug?
@m1lhaus Yes, this does seem to be a bug based on the command-line behavior and the CMake Presets spec. The only time this wouldn't be a bug would be if you're using a presets version prior to v3, but even then, we would require the generator field, so therefore this is definitely a bug and we will mark/treat it as such.
Thanks!
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:
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
Debug Log
No response
Additional Information
No response