qmake: Add QMAKE_SONAME_PREFIX variable

If defined, the value of this variable is prepended to the built shared
library's SONAME identifier.

For more information, see: qmake/doc/src/qmake-manual.qdoc#qmake-soname-prefix

Task-number: QTBUG-31814
Change-Id: I4bceaf0c93162e4fad6bb424af1b82e74d38acdc
Reviewed-by: Jake Petroules <jake.petroules@petroules.com>
This commit is contained in:
Adam Strzelecki 2014-08-06 18:53:05 +02:00 committed by Jake Petroules
parent 935186d76e
commit af155105a9
3 changed files with 52 additions and 0 deletions

View File

@ -970,3 +970,15 @@ int main() { return featureFunction(); }
# <project root>/project.pro # <project root>/project.pro
qtCompileTest(test) qtCompileTest(test)
#! [182] #! [182]
#! [183]
# <project root>/project.pro
QMAKE_SONAME_PREFIX = @rpath
#! [183]
#! [184]
# <project root>/project.pro
QMAKE_SONAME_PREFIX = @executable_path/../Frameworks
QMAKE_SONAME_PREFIX = @loader_path/Frameworks
QMAKE_SONAME_PREFIX = /Library/Frameworks
#! [184]

View File

@ -2071,6 +2071,39 @@
qmake or \l{#QMAKESPEC}{qmake.conf} and rarely qmake or \l{#QMAKESPEC}{qmake.conf} and rarely
needs to be modified. needs to be modified.
\section1 QMAKE_SONAME_PREFIX
If defined, the value of this variable is used as a path to be prepended to
the built shared library's \c SONAME identifier. The \c SONAME is the
identifier that the dynamic linker will later use to reference the library.
In general this reference may be a library name or full library path. On OS
X and iOS, the path may be specified relatively using the following
placeholders:
\table
\header \li Placeholder \li Effect
\row \li @rpath
\li Expands to paths defined by LC_RPATH mach-o commands in
the current process executable or the referring libraries.
\row \li @executable_path
\li Expands to the current process executable location.
\row \li @loader_path
\li Expands to the referring executable or library location.
\endtable
In most cases, using \c @rpath is sufficient and recommended:
\snippet code/doc_src_qmake-manual.pro 183
However, the prefix may be also specified using different placeholders, or
an absolute path, such as one of the following:
\snippet code/doc_src_qmake-manual.pro 184
For more information, see
\l{https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/dyld.1.html}{dyld}
documentation on dynamic library install names.
\section1 QMAKE_TARGET \section1 QMAKE_TARGET
Specifies the name of the project target. The value of this Specifies the name of the project target. The value of this

View File

@ -1265,6 +1265,13 @@ void UnixMakefileGenerator::init2()
if(!instpath.endsWith(Option::dir_sep)) if(!instpath.endsWith(Option::dir_sep))
instpath += Option::dir_sep; instpath += Option::dir_sep;
soname.prepend(instpath); soname.prepend(instpath);
} else if (!project->isEmpty("QMAKE_SONAME_PREFIX")) {
QString sonameprefix = project->first("QMAKE_SONAME_PREFIX").toQString();
if (!sonameprefix.startsWith('@') && !sonameprefix.startsWith('$'))
sonameprefix = Option::fixPathToTargetOS(sonameprefix, false);
if (!sonameprefix.endsWith(Option::dir_sep))
sonameprefix += Option::dir_sep;
soname.prepend(sonameprefix);
} }
project->values("QMAKE_LFLAGS_SONAME").first() += escapeFilePath(soname); project->values("QMAKE_LFLAGS_SONAME").first() += escapeFilePath(soname);
} }