Export compile_commands.json in standalone builds (by default) - #314
Export compile_commands.json in standalone builds (by default) #314Sjors wants to merge 2 commits into
Conversation
Makes clangd and other tooling work out of the box after configuring. Only applied when libmultiprocess is the top-level project, so it does not opt targets into a parent project's compile database when built as a subtree. An explicit -DCMAKE_EXPORT_COMPILE_COMMANDS=OFF or environment variable setting still takes precedence: project() copies the environment value into the cache, leaving the cache entry empty when neither is set, so the default only applies to an empty value. Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
clangd only searches ancestor directories of a source file for compile_commands.json, so even with CMAKE_EXPORT_COMPILE_COMMANDS enabled it would not find the database in the build directory without a symlink in the source directory. Point it at the build/ directory suggested by doc/install.md and doc/usage.md. Developers using a differently named build directory can override this with clangd's --compile-commands-dir flag or a personal clangd user config, which takes precedence over this file. Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ReviewsSee the guideline and AI policy for information on the review process. |
|
Code review fab9081. I think we should do something to make this less cumbersome, but I'm not sure about this approach, especially since it hardcodes the name of the But I've also been thinking it would be good to have a clearer separation in the cmake build between essential features that can't be provided externally and convenience features and maybe just enable the convenience features in a dev mode present like Bitcoin core. Sketch of this idea is: master...ryanofsky:libmultiprocess:pr/extras (branch) which would automatically set up this editor support if dev mode is enabled while avoiding a hardcoded .clangd file, and simplifying the main cmake file instead of complicating it. |
|
Closing in favor of your suggested approach. I won't have time in the next two weeks to implement that though. |
This makes the default build configuration play nicely with code editors. E.g. with Zed, looking at
spawn_argvin #231:Before:

After:

One downside of this approach is that it only just works(tm) on the
builddirectory.There are several alternative approaches: