aboutsummaryrefslogtreecommitdiffstats
path: root/share/qbs/modules
diff options
context:
space:
mode:
Diffstat (limited to 'share/qbs/modules')
-rw-r--r--share/qbs/modules/cpp/CppModule.qbs1
-rw-r--r--share/qbs/modules/cpp/gcc.js12
2 files changed, 13 insertions, 0 deletions
diff --git a/share/qbs/modules/cpp/CppModule.qbs b/share/qbs/modules/cpp/CppModule.qbs
index efda896da..bdd6d2750 100644
--- a/share/qbs/modules/cpp/CppModule.qbs
+++ b/share/qbs/modules/cpp/CppModule.qbs
@@ -191,6 +191,7 @@ Module {
property bool useRPathLink
property string rpathLinkFlag
property bool discardUnusedData
+ property bool removeDuplicateLibraries: true
property stringList assemblerFlags
PropertyOptions {
diff --git a/share/qbs/modules/cpp/gcc.js b/share/qbs/modules/cpp/gcc.js
index 639191da6..574fe769b 100644
--- a/share/qbs/modules/cpp/gcc.js
+++ b/share/qbs/modules/cpp/gcc.js
@@ -80,8 +80,20 @@ function collectLibraryDependencies(product, isDarwin) {
var objectByFilePath = {};
var tagForLinkingAgainstSharedLib = product.cpp.imageFormat === "pe"
? "dynamiclibrary_import" : "dynamiclibrary";
+ var removeDuplicateLibraries = product.cpp.removeDuplicateLibraries
function addObject(obj, addFunc) {
+ /* If the object is already known, remove its previous usage and insert
+ * it again in the new desired position. This preserves the order of
+ * the other objects, and is analogous to what qmake does (see the
+ * mergeLflags parameter in UnixMakefileGenerator::findLibraries()).
+ */
+ if (removeDuplicateLibraries && (obj.filePath in objectByFilePath)) {
+ var oldObj = objectByFilePath[obj.filePath];
+ var i = objects.indexOf(oldObj);
+ if (i >= 0)
+ objects.splice(i, 1);
+ }
addFunc.call(objects, obj);
objectByFilePath[obj.filePath] = obj;
}