blob: c49cb77c2e35dffdc5bb6ef9f65cdc207bc3cba4 (
plain)
1 From 205225994c631aa1310778c304b7ee62ee2701ef Mon Sep 17 00:00:00 2001
2 From: Joerg Bornemann <joerg.bornemann@qt.io>
3 Date: Wed, 31 Jul 2019 10:55:14 +0200
4 Subject: [PATCH] Fix dependency_libs entry of .la files
5
6 Libtool cannot cope with absolute paths in the dependency_libs entry.
7 We split absolute paths into -L and -l here.
8
9 Change-Id: I30bf11e490d1993d2a4d88c114e07bbae12def6d
10 Fixes: QTBUG-76625
11 Reviewed-by: Kai Koehne <kai.koehne@qt.io>
12 ---
13
14 diff --git a/qmake/generators/unix/unixmake2.cpp b/qmake/generators/unix/unixmake2.cpp
15 index d9bcccf..abc3714 100644
16 --- a/qmake/generators/unix/unixmake2.cpp
17 +++ b/qmake/generators/unix/unixmake2.cpp
18 @@ -1450,7 +1450,36 @@
19 void
20 UnixMakefileGenerator::writeLibtoolFile()
21 {
22 + auto fixDependencyLibs
23 + = [this](const ProStringList &libs)
24 + {
25 + ProStringList result;
26 + for (auto lib : libs) {
27 + auto fi = fileInfo(lib.toQString());
28 + if (fi.isAbsolute()) {
29 + const QString libDirArg = "-L" + fi.path();
30 + if (!result.contains(libDirArg))
31 + result += libDirArg;
32 + QString namespec = fi.fileName();
33 + int dotPos = namespec.lastIndexOf('.');
34 + if (dotPos != -1 && namespec.startsWith("lib")) {
35 + namespec.truncate(dotPos);
36 + namespec.remove(0, 3);
37 + } else {
38 + debug_msg(1, "Ignoring dependency library %s",
39 + lib.toLatin1().constData());
40 + continue;
41 + }
42 + result += "-l" + namespec;
43 + } else {
44 + result += lib;
45 + }
46 + }
47 + return result;
48 + };
49 +
50 QString fname = libtoolFileName(), lname = fname;
51 + debug_msg(1, "Writing libtool file %s", fname.toLatin1().constData());
52 mkdir(fileInfo(fname).path());
53 int slsh = lname.lastIndexOf(Option::dir_sep);
54 if(slsh != -1)
55 @@ -1488,12 +1517,11 @@
56 << ".a'\n\n";
57
58 t << "# Libraries that this one depends upon.\n";
59 + static const ProKey libVars[] = { "LIBS", "QMAKE_LIBS" };
60 ProStringList libs;
61 - libs << "LIBS" << "QMAKE_LIBS";
62 - t << "dependency_libs='";
63 - for (ProStringList::ConstIterator it = libs.begin(); it != libs.end(); ++it)
64 - t << fixLibFlags((*it).toKey()).join(' ') << ' ';
65 - t << "'\n\n";
66 + for (auto var : libVars)
67 + libs += fixLibFlags(var);
68 + t << "dependency_libs='" << fixDependencyLibs(libs).join(' ') << "'\n\n";
69
70 t << "# Version information for " << lname << "\n";
71 int maj = project->first("VER_MAJ").toInt();
|