Remove duplicate libraries added via prl files in Windows
authorMiikka Heikkinen <miikka.heikkinen@digia.com>
Wed, 28 Nov 2012 11:21:15 +0000 (13:21 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Fri, 30 Nov 2012 07:22:35 +0000 (08:22 +0100)
The LIBS statement generated into Makefiles contained duplicate
libraries when application was linking static libraries.

Fixed by adapting the logic from unixmake.cpp's version of
processPrlFiles() to remove duplicates.

Change-Id: I12e152900233d0376b7d7ac6cd18a92850a6d640
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
qmake/generators/win32/winmakefile.cpp

index 8bd4537..2fb1fb9 100644 (file)
@@ -245,6 +245,23 @@ Win32MakefileGenerator::processPrlFiles()
                 l.insert(lit + prl + 1, prl_libs.at(prl));
             prl_libs.clear();
         }
+
+        // Merge them into a logical order
+        if (!project->isActiveConfig("no_smart_library_merge") && !project->isActiveConfig("no_lflags_merge")) {
+            ProStringList lflags;
+            for (int lit = 0; lit < l.size(); ++lit) {
+                ProString opt = l.at(lit).trimmed();
+                if (opt.startsWith(libArg)) {
+                    if (!lflags.contains(opt))
+                        lflags.append(opt);
+                } else {
+                    // Make sure we keep the dependency-order of libraries
+                    lflags.removeAll(opt);
+                    lflags.append(opt);
+                }
+            }
+            l = lflags;
+        }
     }
 }