Qmake custom compilers: how to process generated header files with moc
-
I've a code generator which generates QObject based classes,
to use it with qmake I defined a custom compiler (see below).
Both files were generated correctly, but my problem is, the generated header file should be processed by the moc compiler.
I cannot figure out how to do this.
If I try the undocumented config option moc_verify no header files will be generated at all.Does anyone know a solution, or is this impossible?
gen_h.name = generator custom compiler - ${QMAKE_FILE_IN}
gen_h.input = GEN_INPUT
gen_h.output = ${QMAKE_FILE_BASE}.h
gen_h.commands = generator ${QMAKE_FILE_NAME} --outputheader ${QMAKE_FILE_OUT}
gen_h.CONFIG += target_predeps
gen_h.dependency_type = TYPE_C
gen_h.variable_out = HEADERS
QMAKE_EXTRA_COMPILERS += gen_hgen_cpp.name = generator custom compiler - ${QMAKE_FILE_IN}
gen_cpp.input = GEN_INPUT
gen_cpp.output = ${QMAKE_FILE_BASE}.cpp
gen_cpp.commands = generator ${QMAKE_FILE_NAME} --outputimplementation ${QMAKE_FILE_OUT} --include ${QMAKE_FILE_BASE}.h
gen_cpp.CONFIG += target_predeps
gen_cpp.dependency_type = TYPE_C
gen_cpp.variable_out = GENERATED_SOURCES
QMAKE_EXTRA_COMPILERS += gen_cpp -
From the digia support I've heard, that I should add moc_verify to the CONFIG of the custom compiler.
gen_cpp.CONFIG += target_predeps moc_verify
They send me a simple example where it works, but for my concrete pro files it doesn't work.
So they send me a patch for qmake, which also doesn't help,
so I'm stuck with this.--- a/qmake/generators/makefile.cpp
+++ b/qmake/generators/makefile.cpp
@@ -1636,7 +1636,8 @@ MakefileGenerator::verifyExtraCompiler(const QString &comp, const QString &file_
if(project->values(comp + ".CONFIG").indexOf("moc_verify") != -1) {
if(!file.isNull()) {
QMakeSourceFileInfo::addSourceFile(file, QMakeSourceFileInfo::SEEK_MOCS);-
if(!mocable(file)) {
-
// If it does not exist we assume it will be mocable for now
-
if(QFile::exists(file) && !mocable(file)) { return false; } else { project->values("MOCABLES").append(file);
-