Using Ninja directly with -t compdb
You can use Ninja’s built-in tool to generate the compile_commands.json.
$ ninja -t compdb > compile_commands.json
-t compdbtells Ninja to output the compilation database.- Redirect the output to
compile_commands.json.