microsoft / vscode-cmake-tools

CMake integration in Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=vector-of-bool.cmake-tools
MIT License
1.48k stars 455 forks source link

Command Request: Refresh CMakePresets #3974

Closed dornbirndevelops closed 3 months ago

dornbirndevelops commented 3 months ago

Brief Issue Summary

In my daily development work, I mostly work with CMake projects in combination with the C/C++ Package Manager conan.

CMakePresets.json are usually not checked in to my source code, but I rather rely on the generated CMakeUserPresets.json. Sometimes I either open the project in VS Code without running conan first, or I clean all generated files from the project by removing all files under gitignore.

(Re-)generating the presets does not appear to be recognized by the extension. The only thing that helps in this situation is to use the Developer: Reload Window command. It would be nice to have a command that just re-attempts parsing the local preset files which were created in the meantime without having to reload the whole window.

CMake Tools Diagnostics

No response

Debug Log

No response

Additional Information

open project with no preset files image

open project after generating preset files image

open project with preset files after manual window reload image

andreas-kurz commented 3 months ago

Thanks for bringing this up :) I was also stumbling over that issue as rebasing branches containing CMakePresets also doesn't consistently trigger a preset reload. Up to now my approach was to close and reopen VS Code – "Reload Window" works much better and faster.

Would highly appreciate if a preset reload could be triggered from somewhere in the plugin.

gcampbell-msft commented 3 months ago

@andreas-kurz @dornbirndevelops Does opening the presets file and saving it again work? Assuming you have the cmake.configureOnEdit setting enabled, I believe this should work

dornbirndevelops commented 3 months ago

Does opening the presets file and saving it again work? Assuming you have the cmake.configureOnEdit setting enabled, I believe this should work

Thank you for responding to my issue @andreas-kurz and @gcampbell-msft !

I just tried your suggestion with setting "cmake.configureOnEdit": true and changing CMakeUserPresets.json and CMakeLists.txt, unfortunately without the desired outcome. It appears that the setting does nothing if no configure preset is selected.

andreas-kurz commented 3 months ago

In our project cmake.configureOnEdit is set to true from the beginning. It seems that is only watching for files likeCMakeLists.txt – at least the comment for the settings says this. Also, we are not using CMakeUserPresets – just CMakePresets.json

So CMakePresets are somewhat different and I don't know what makes the cmake extension parse these files despite a Reload Window which is much better than completely closing and re-opening vs code.

Therefore an option to re-parse the settings would be great or some way of auto-re-parsing if the extension detects changes to the CMakePresets (which also supports includes!).

gcampbell-msft commented 3 months ago

@andreas-kurz The current implementation should be reparsing on every save of the CMakePresets.json, especially in the most recent version of the pre-release (as of 1.19.44).

andreas-kurz commented 3 months ago

Thanks for the hint with "pre-release" – didn't noticed that before :)

I'll test it and will provide feedback – maybe next week as in Germany it's almost weekend ;)

How long does it usually take until pre-release feature make it into the actual release?

Edit: I was too curious and justed tested the pre-release version of the extension. Works like a charm =)

Our setup is having a CMakePresets.json with multiple levels of includes and no matter where I do changes it's always automatically reparsed with the respective output. So that feature seems to work (on my machine).

Thanks and have a nice weekend :)

gcampbell-msft commented 3 months ago

Thanks for the confirmation! @andreas-kurz

andreas-kurz commented 3 months ago

Thanks, it already made it to the Release :)

Just switched back and edited some presets and includes and every edit triggered the reparsing of the presets with includes <3

dornbirndevelops commented 3 months ago

Hello @gcampbell-msft !

I also just tried the pre-release version v1.19.46. I set "cmake.configureOnEdit": true and generated the CMakeUserPresets.json (there was none before). This did not work out for me unfortunately, as it did not parse the newly added presets file.

Since the issue is not solved (at least for me), could you maybe reopen this issue or should I create a new one?

EDIT: To my surprise, it is now also unable to parse the CMakeUserPresets.json file, even after reloading!

gcampbell-msft commented 3 months ago

@dornbirndevelops Please create a new issue and we will investigate. Any information about how it's not able to parse would be exceedingly helpful. If it's unable to parse the file, there is either something wrong with your presets file, or there is a bug on our end. Thanks!

dornbirndevelops commented 3 months ago

Thanks for the quick reply. I will make a new issue then.