Generate dependencies for moc_ style includes when using CONFIG+=GNUmake
authorTor Arne Vestbø <tor.arne.vestbo@nokia.com>
Thu, 20 Oct 2011 08:53:28 +0000 (10:53 +0200)
committerQt by Nokia <qt-info@nokia.com>
Thu, 20 Oct 2011 14:49:24 +0000 (16:49 +0200)
Sometimes you will include "moc_foo.cpp" from a a cpp file, not to tell
qmake to run moc on it (that's handled by having foo.h in HEADERS), but
so that the moc'ed sources are compiled as part of foo.cpp instead of a
separate compilation unit, or if the moc'ed sources need defintions from
the cpp file.

The dependency logic for CONFIG+=GNUmake failed to take this case into
account, resulting in failures to find files when generating dependency
information for those files.

Change-Id: Iac00424e2d196b518b1ef576d7567335b8ff24f0
Reviewed-by: Simon Hausmann <simon.hausmann@nokia.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
qmake/generators/unix/unixmake2.cpp

index 70a7d66..2037e3f 100644 (file)
@@ -323,7 +323,8 @@ UnixMakefileGenerator::writeMakeParts(QTextStream &t)
 
                     if(!d_file.isEmpty()) {
                         d_file = odir + ".deps/" + fileFixify(d_file, pwd, Option::output_dir) + ".d";
-                        QStringList deps = findDependencies((*it)).filter(QRegExp(Option::cpp_moc_ext + "$"));
+                        QStringList deps = findDependencies((*it)).filter(QRegExp(
+                                    "((^|/)" + Option::h_moc_mod + "|" + Option::cpp_moc_ext + "$)"));
                         if(!deps.isEmpty())
                             t << d_file << ": " << deps.join(" ") << endl;
                         t << "-include " << d_file << endl;