Repository navigation
Make Visual Studio CMake integration work #99584
Description
Currently the flow for native debugging of a Windows project is to run flutter build windows at least once, then open the sln file that's created in build/windows/ and run from there. This is not at all intuitive, and has the downside that people may not realize that changes they make there aren't permanent.
Visual Studio also has the ability to directly open a directory with a CMake project, but currently it doesn't work (largely because when I was doing the build conversion to CMake, the VS/CMake integration was completely broken on my machine, and it was never enough of a priority to come back to.) It default to the ninja generator, which our Windows CMake files don't currently support (they are written exclusively for multi-config generators), and it looks like it also defaults to clang-cl. It looks like we should be able to add a configuration file to the template that would set:
- the generator (we wouldn't be able to do this dynamically, but we could just set it to VS 2022 and people could change it if they needed to)
- the compiler
- ideally the build output folder so it's using the same destination we are
- anything else that needs adjusting from defaults
We should see if just doing that makes it possible for someone to get a good VS experience without having to ever deal with the generated solution file. (One thing we'll need to look at is how it handles the install step, since we've co-opted that to make the self-contained bundle that's needed to run.) If so, we should add that to the template.
Activity
sebastianhaberey commentedon May 13, 2022
That would be helpful, not only for VS 2022 but also for VS Code.
baneeishaque commentedon Sep 3, 2023
CLion too...
flutter-triage-bot commentedon Jun 6, 2024
The
triaged-desktoplabel is irrelevant if there is noteam-desktoplabel orfyi-desktoplabel.Gustl22 commentedon Aug 14, 2026
I managed to debug in CLion (or more precisely in IntelliJ Ultimate with CLion + CMake plugin) with below patch to a flutter app project. Maybe this helps for implementing generated files
CMakePresets.json(ckecked-in on project platform generation) andCMakeUserPresets.json(.gitignore'd, possibly should be generated onflutter build windows --config-onlyif not existent, as environments differ from system to system).See: https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html
flutter build windows --config-onlywindowsdirectory in a new IDE windowDepending on your setup, more work is required: e.g. installing a debugger, e.g. LLVM lldb-dap with python etc., if no built-in debugger is available.
Patch for Debugging from Native Windows project
I supect a similar approach is possible on Visual Studio and VSCode.
Edit: And this patch also must land first: #190873, but can also be applied just to your current project.
[Windows] fix: Remove quotes from compiler warning suppression (flutt…