One compilation database including external projects?

Is there a way to get cmake to generate one compilation database (compile_commands.json) for the entire project including external projects? Currently every external project gets its own db. Or is there a cmake way to merge all dbs to one?

CMake provides no mechanism as external projects are outside of its control beyond “a bag of commands to run in order”. Additionally, these databases wouldn’t exist until after the build is underway which is far after the local project’s database is written out. jq could probably be used to combine everything though.

Valid point, forgot that the configure step for externals happens when build is underway. Thanks for the jq tip!

Found a better way if using vscode, then let it merge the compilation databases by setting this attribute; cmake.mergedCompileCommands