From f6238e2d3bd96597a618978175b558d0bdbb3be6 Mon Sep 17 00:00:00 2001 From: Matthias Doerfel Date: Sat, 4 May 2019 19:51:53 +0300 Subject: 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 () 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 --- qmake/generators/makefiledeps.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'qmake') 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) { if(!includes) 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 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; files->addFile(dep); - includes->addFile(dep, inc, false); + /* QTBUG-72383: Local includes "foo.h" are keyed by the resolved + * path (stored in dep itself), only global includes are + * unique keys immediately. */ + const char *key = try_local ? nullptr : inc; + includes->addFile(dep, key, false); } dep->exists = exists; } -- cgit v1.2.3