From 6a221f3d05b6d0e902d86d75428364747268c6c9 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Fri, 7 Dec 2018 10:36:08 +0100 Subject: Fix qmake's detection for conflicting source files for nmake Consider the following source tree: foo/narf.cpp bar/narf.c bar/gnampf.cpp The .pro file has SOURCES += foo/narf.cpp bar/gnampf.cpp The file bar/narf.c is not supposed to be built for whatever reason. QMake's nmake Makefile generator generates inference rules of the form {.\foo}.cpp{debug\}.obj:: ... for every source subdirectory and every source file extension. Thus, we have {.\foo}.cpp{debug\}.obj:: {.\bar}.cpp{debug\}.obj:: {.\bar}.c{debug\}.obj:: Depending on the exact execution order of the inference rules (which depends on the names of the files) the latter rule might get picked, and we're erronously compiling bar/narf.c even though it's not referenced in the .pro file. Conclusion: QMake's detection of conflicting source files must consider the base names of source files, and not the exact file names. Fixes: QTBUG-72059 Change-Id: I50c2725ae2a7421053369a10680230f571af00ea Reviewed-by: Oliver Wolff Reviewed-by: Oswald Buddenhagen --- qmake/generators/win32/msvc_nmake.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'qmake') diff --git a/qmake/generators/win32/msvc_nmake.cpp b/qmake/generators/win32/msvc_nmake.cpp index 306ae57871..780f6bd4d8 100644 --- a/qmake/generators/win32/msvc_nmake.cpp +++ b/qmake/generators/win32/msvc_nmake.cpp @@ -553,12 +553,13 @@ void NmakeMakefileGenerator::writeImplicitRulesPart(QTextStream &t) QDirIterator dit(sourceDir, sourceFilesFilter, QDir::Files | QDir::NoDotAndDotDot); while (dit.hasNext()) { dit.next(); - QString &duplicate = fileNames[dit.fileName()]; + const QFileInfo fi = dit.fileInfo(); + QString &duplicate = fileNames[fi.completeBaseName()]; if (duplicate.isNull()) { - duplicate = dit.filePath(); + duplicate = fi.filePath(); } else { warn_msg(WarnLogic, "%s conflicts with %s", qPrintable(duplicate), - qPrintable(dit.filePath())); + qPrintable(fi.filePath())); duplicatesFound = true; } } -- cgit v1.2.3