vscode-cmake-tools
vscode-cmake-tools copied to clipboard
CMakePresets don't work with MSVC when using Remote/SSH, and are painful when running locally
Brief Issue Summary
To get presets that are designed for cross-platform projects (so, using ninja generator, etc - I haven't tried using the Visual Studio/vcproj generators because I do not want to use them and never had to use them before Presets) to work:
- when running locally, I have to close all vscode windows, then launch it from within a terminal window that has the developer environment variables set. (I wrap
Enter-VsDevShellwith this https://gitlab.freedesktop.org/ryan.pavlik/powershell-enter-vsdevenv so I can get to it quicker, but it's still a pain) - When running over SSH using the official Remote SSH extension into a Windows machine, since I do not have system environment variables set to include the MSVC developer paths, I cannot use this extension's build support at all, because the presence of CMakePresets.json turns off existing toolchain-finding, and there's no way I know of to call Enter-VsDevShell in the vscode server's shell before it launches.
- As a workaround, I either only build from the embedded terminal manually (where I can call Enter-VsDevShell), or I simply delete the presets file so I can get the old Kits behavior back.
I think the fundamental problem here is that the kits and CMakePresets are not inherently in conflict, but are treated as such by the extension. It might be OK to default to not setting up kits when you have a presets file, but I want to be able to tell the extension to please set up the environment for a kit before doing what the presets file says. This doesn't matter as much on Linux where there are standard system locations for a toolchain (though I would still like to pick which one), but on Windows with MSVC installed as usual, you can't just run cmake (at least using any non-vcproj generator) from a command line with no advance setup.
This is actively keeping me from using the otherwise nice CMakePresets functionality because it makes developing and contributing to projects on Windows so painful.
CMake Tools Diagnostics
No response
Debug Log
No response
Additional Information
No response
Related to this: https://github.com/microsoft/vscode-cmake-tools/issues/2912
Same basic pain point.
@rpavlik Thanks for your report.
A clarifying question: You mentioned that "the presence of CMakePresets.json turns off existing toolchain-finding". Are you referencing the finding of toolchains or are you referencing the usage and finding of kits?
Additionally, have you confirmed that MSVC is installed on your Windows remote machine?
Thanks for any information that can help us investigate.
Sorry, yes I meant kits. The stuff is definitely installed, I just don't always want to turn sideways to use my windows laptop (bad ergonomics) so I see this when using ssh from my Linux desktop. Works fine without presets files, but put a preset file there and you've got trouble. The project I first noticed this with is https://gitlab.freedesktop.org/monado/monado but any with similar presets files will do it. My colleagues have also seen this and will just delete the presets files to get the original behavior back even when not using ssh. (And I'm blocking merge of presets files in the project root in other projects to avoid this problem.)