From b9e8d85fb254bbec78d75b7c6d23045a4c8aa965 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Tue, 17 Aug 2021 17:11:20 +0200 Subject: [PATCH] Fix framework dependencies in .la files "-framework Foo" arguments must be placed in the inherited_linker_flags variables instead of dependency_libs. Pick-to: 5.15 Fixes: QTBUG-2390 Change-Id: Idec4115533ed1f86f44db64931fa64cadeeb4572 Reviewed-by: Alexandru Croitor --- qmake/generators/unix/unixmake2.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/qmake/generators/unix/unixmake2.cpp b/qmake/generators/unix/unixmake2.cpp index 190f5e355a8..d5a057ef7ba 100644 --- a/qmake/generators/unix/unixmake2.cpp +++ b/qmake/generators/unix/unixmake2.cpp @@ -37,6 +37,9 @@ #include #include +#include +#include + QT_BEGIN_NAMESPACE void @@ -1422,6 +1425,25 @@ UnixMakefileGenerator::libtoolFileName(bool fixify) return ret; } +static std::pair +splitFrameworksAndLibs(const ProStringList &linkArgs) +{ + std::pair result; + bool frameworkArg = false; + for (auto arg : linkArgs) { + if (frameworkArg) { + frameworkArg = false; + result.second += arg; + } else if (arg == "-framework") { + frameworkArg = true; + result.second += arg; + } else { + result.first += arg; + } + } + return result; +} + void UnixMakefileGenerator::writeLibtoolFile() { @@ -1496,7 +1518,13 @@ UnixMakefileGenerator::writeLibtoolFile() ProStringList libs; for (auto var : libVars) libs += fixLibFlags(var); + ProStringList frameworks; + std::tie(libs, frameworks) = splitFrameworksAndLibs(libs); t << "dependency_libs='" << fixDependencyLibs(libs).join(' ') << "'\n\n"; + if (!frameworks.isEmpty()) { + t << "# Frameworks that this library depends upon.\n"; + t << "inherited_linker_flags='" << frameworks.join(' ') << "'\n\n"; + } t << "# Version information for " << lname << "\n"; int maj = project->first("VER_MAJ").toInt();