Comment by TuxSH
9 months ago
> and finding that I could only get it to generate with a specific compiler chain on windows (ninja I think?)
Yes, you're right about that.
Basically, it boils down to "use CMake with Ninja/Makefile" (even if you don't strictly have to, you could write a script that creates the json yourself, for example). When cross-compiling, you may also have to whitelist compiler paths.
Add -DCMAKE_EXPORT_COMPILE_COMMANDS=ON as command-line arg during the config step, or add the equivalent "set" call to your CMakeLists.txt, restart clangd (ctrl+p, restart clangd), and you're good to go.
There are minor annoyances when cross-compiling (it using clang -- some compile options are incompatible and need to be removed in global user config, and it not extracting default compiler defines from compilers) but they are very easily worked around
I more or less use this as config: https://gist.github.com/TuxSH/0220d1235dace77f82738c96718011...
No comments yet
Contribute on Hacker News ↗