Closed TishSerg closed 4 months ago
Thank you for reporting this issue. We may not be able to get to this issue immediately, however, we accept PRs from the community. This is the place in code that needs to include the target architecture. https://github.com/microsoft/vscode-cmake-tools/blob/86a48bf30dc449178fd63c7d5458f2807fdbbc16/src/kit.ts#L1220-L1226
I was able to repro this issue. Investigating a fix
hey @TishSerg This issue should now be fixed in pre-release. If possible try it out and let me know if it works for you :)
Verified on CMake Tools v1.18.43(release), this issue was fixed: switching from kit 1 to kit 2 (after successful build on kit 1), CMake Cache gets removed.
@Ashley-Li Thanks for confirming!
Brief Issue Summary
The cache is not deleted when switching to a kit with a different target arch, but the same host arch. It results in error during building:
I detailed this in the Additional Info section. If logs are still needed, let me know. I'll add them.
CMake Tools Diagnostics
No response
Debug Log
No response
Additional Information
I want to compile an MSVC project for x86 and x64. I do switch target arch by switching the kit in CMake Tools Statusbar: As you can see, there are 4 compilers/kits available:
C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.33.31629/bin/Hostx64/x64/cl.exe
C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.33.31629/bin/Hostx64/x86/cl.exe
C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.33.31629/bin/Hostx86/x86/cl.exe
C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.33.31629/bin/Hostx86/x64/cl.exe
The host arch is tagged with a green line in the picture, and the target arch is tagged with a cyan line.
When I switch between the kits with the different host arch, CMake Cache gets removed. Example of switching from kit 1 to kit 3 (after successful build on kit 1):
Then on the build, CMake configures the folder and successfully builds an
exe
.But when switching kits with the same host arch, CMake doesn't remove the Cache. Example of switching from kit 1 to kit 2 (after successful build on kit 1):
As you can see it lacks
Removing
Cache lines. Then on the build, CMake tries to configure the folder, but fails:To fix that I have to execute in command palette
>CMake: Delete Cache and Reconfigure
. Only after this, I can successfully build with the new kit selected.Expected behavior: Remove the Cache when the target arch is switched.
Albeit, I don't know if the Cache removal is necessary when only the host arch is switched (current behavior), i.e [kit 1] ↔ [kit 4] or [kit 2] ↔ [kit 3]. Maybe it's ok to not remove the Cache in this situation. Maybe it was intended behavior, but someone messed that up and set Cache removal on host arch switching instead of target arch switching?