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.
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.
1 Answer
Reset to default 0In the qmake man page, there's no such option.
If we have a look at the source of Qt Creator, the logic is in src/plugins/cppeditor/compilationdb.cpp. They use their own implementation to genreate compile_commands.json
. It would be possible to create a standalone CLI program from it with some effort.
const QString fileName = "compile_commands.json";
//...
QFile compileCommandsFile(baseDir.pathAppended(fileName).toFSPathString());
const bool fileOpened = compileCommandsFile.open(QIODevice::WriteOnly | QIODevice::Truncate);
//...
compileCommandsFile.write("[");
const QJsonArray jsonProjectOptions = QJsonArray::fromStringList(projectOptions);
// More logic to write the file
compileCommandsFile.write("]");
compileCommandsFile.close();
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744890551a4599385.html
评论列表(0条)