diff options
authorMatthias Doerfel <>2019-05-04 19:51:53 +0300
committerKai Koehne <>2019-05-07 08:41:09 +0000
commitf6238e2d3bd96597a618978175b558d0bdbb3be6 (patch)
parentb5154b5254950427383c96a382457fa0bb87e69e (diff)
qmake: Distinguish local header files by directory and name
Information about header files is cached by qmake. The key is the filename of the #include directive. For system includes (<stdio.h>) this is unique, according to the search order in INCLUDE_PATH. For local includes, given as "foo.h", there may be name collisions. Usually a compiler first searches in the directory of the current file (stored in the sourceDir variable), and only in case of a miss the INCLUDE_PATH is considered. The dependency generation now distinguishes local header files by their full relative path. This is implemented by forcing the use of the full relative path as key into the SourceFiles data structure if the flag try_local is set. Change-Id: Ifd75325b53496824054595f7fc98d71bbd9d8aa6 Fixes: QTBUG-72383 Reviewed-by: Joerg Bornemann <>
1 files changed, 8 insertions, 2 deletions
diff --git a/qmake/generators/makefiledeps.cpp b/qmake/generators/makefiledeps.cpp
index decc1d980c..1aab1987d2 100644
--- a/qmake/generators/makefiledeps.cpp
+++ b/qmake/generators/makefiledeps.cpp
@@ -837,7 +837,9 @@ bool QMakeSourceFileInfo::findDeps(SourceFile *file)
if(inc) {
includes = new SourceFiles;
- SourceFile *dep = includes->lookupFile(inc);
+ /* QTBUG-72383: Local includes "foo.h" must first be resolved relative to the
+ * sourceDir, only global includes <bar.h> are unique. */
+ SourceFile *dep = try_local ? nullptr : includes->lookupFile(inc);
if(!dep) {
bool exists = false;
QMakeLocalFileName lfn(inc);
@@ -876,7 +878,11 @@ bool QMakeSourceFileInfo::findDeps(SourceFile *file)
dep->file = lfn;
dep->type = QMakeSourceFileInfo::TYPE_C;
- includes->addFile(dep, inc, false);
+ /* QTBUG-72383: Local includes "foo.h" are keyed by the resolved
+ * path (stored in dep itself), only global includes <bar.h> are
+ * unique keys immediately. */
+ const char *key = try_local ? nullptr : inc;
+ includes->addFile(dep, key, false);
dep->exists = exists;