summaryrefslogtreecommitdiffstats
path: root/qmake
diff options
context:
space:
mode:
Diffstat (limited to 'qmake')
-rw-r--r--qmake/doc/src/qmake-manual.qdoc23
-rw-r--r--qmake/generators/unix/unixmake.cpp19
2 files changed, 39 insertions, 3 deletions
diff --git a/qmake/doc/src/qmake-manual.qdoc b/qmake/doc/src/qmake-manual.qdoc
index cfa288da82..535b500fd3 100644
--- a/qmake/doc/src/qmake-manual.qdoc
+++ b/qmake/doc/src/qmake-manual.qdoc
@@ -1845,6 +1845,22 @@
The value of this variable is typically handled by
qmake or \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified.
+ \section1 QMAKE_LFLAGS_REL_RPATH
+
+ Specifies the linker flags needed to enable relative paths in
+ \l{QMAKE_RPATHDIR}.
+
+ The value of this variable is typically handled by
+ qmake or \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified.
+
+ \section1 QMAKE_REL_RPATH_BASE
+
+ Specifies the string the dynamic linker understands to be the
+ location of the referring executable or library.
+
+ The value of this variable is typically handled by
+ qmake or \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified.
+
\section1 QMAKE_LFLAGS_RPATHLINK
Specifies the linker flags needed to use the values from
@@ -2095,6 +2111,13 @@
executable at link time so that the paths will be preferentially
searched at runtime.
+ When relative paths are specified, qmake will mangle them into a form
+ understood by the dynamic linker to be relative to the location of
+ the referring executable or library.
+ This is supported only by some platforms (currently Linux and
+ Darwin-based ones) and is detectable by checking whether
+ \l{QMAKE_REL_RPATH_BASE} is set.
+
\section1 QMAKE_RPATHLINKDIR
Specifies a list of library paths for the static linker to search for implicit
diff --git a/qmake/generators/unix/unixmake.cpp b/qmake/generators/unix/unixmake.cpp
index 1d9ebb35e3..57c0a97228 100644
--- a/qmake/generators/unix/unixmake.cpp
+++ b/qmake/generators/unix/unixmake.cpp
@@ -125,10 +125,23 @@ UnixMakefileGenerator::init()
const ProStringList &rpathdirs = project->values("QMAKE_RPATHDIR");
for (int i = 0; i < rpathdirs.size(); ++i) {
QString rpathdir = rpathdirs[i].toQString();
- if (rpathdir.length() > 1 && rpathdir.at(0) == '$' && rpathdir.at(1) != '(')
+ if (rpathdir.length() > 1 && rpathdir.at(0) == '$' && rpathdir.at(1) != '(') {
rpathdir.replace(0, 1, "\\$$"); // Escape from make and the shell
- else if (!rpathdir.startsWith('@'))
- rpathdir = QFileInfo(rpathdir).absoluteFilePath();
+ } else if (!rpathdir.startsWith('@') && fileInfo(rpathdir).isRelative()) {
+ QString rpathbase = project->first("QMAKE_REL_RPATH_BASE").toQString();
+ if (rpathbase.isEmpty()) {
+ fprintf(stderr, "Error: This platform does not support relative paths in QMAKE_RPATHDIR (%s)\n",
+ rpathdir.toLatin1().constData());
+ continue;
+ }
+ if (rpathbase.startsWith('$'))
+ rpathbase.replace(0, 1, "\\$$"); // Escape from make and the shell
+ if (rpathdir == ".")
+ rpathdir = rpathbase;
+ else
+ rpathdir.prepend(rpathbase + '/');
+ project->values("QMAKE_LFLAGS").insertUnique(project->values("QMAKE_LFLAGS_REL_RPATH"));
+ }
project->values("QMAKE_LFLAGS") += var("QMAKE_LFLAGS_RPATH") + escapeFilePath(rpathdir);
}
}