Generate compilation database (compile_command.json) using `qmake` (not GUI)
13:20 08 Mar 2025

There was a self-answered question, How to generate compile_commands.json with QT project?, where the asker however was satisfied with the generation through Qt Creator.

Sadly, that's not an option for me; this needs to work in a CLI workflow on Linux.

Using bear to generate a compilation database from a make is unsatisfactory (and slow).

Since Qt Creator seems to have the functionality, it does exist in FOSS on Linux. (it's in a plugin, unless demonstrated otherwise, I'll assume the plugin environment necessary to run the conversion cannot be replicated without running the GUI.)

How do I create a compile_commands.json from a qmake-targetting .pro file without going through bear, compiledb (and doing a flaky build) or GUI?

Aiming at qmake-qt5, so far.

qmake compilation-database