CMake Ninja show link commands

For CMake, the export of compile commands comes by setting the CMAKE_EXPORT_COMPILE_COMMANDS variable to ON. This generates <build_dir>/compile_commands.json file that contains the compile commands for each source file. However, this does not include the link commands used to link the final executable or library. To show the link commands in Ninja for a specific target, use:

ninja -t compdb-targets mytarg

This command has to be issued directly to Ninja, not using “cmake –build”.