support -rpath for modules which are not installed to QT_INSTALL_PREFIX

a module's project file may set MODULE_INSTALL_LIBS before loading
qt_module.prf to have an alternative RPATH linked into the users of that
module.
this is relevant only for linking against non-installed -prefix builds
of that module, as otherwise .libs from the module's pri file is used
for rpath.

Change-Id: Ib240e748cf130a71a5991dc643c368a983092ead
Reviewed-by: Simon Hausmann <simon.hausmann@nokia.com>
Reviewed-by: Joerg Bornemann <joerg.bornemann@nokia.com>
This commit is contained in:
Oswald Buddenhagen 2012-08-09 15:02:44 +02:00 committed by Qt by Nokia
parent 43af0260b8
commit b603fd36c2
4 changed files with 14 additions and 7 deletions

9
configure vendored
View File

@ -5345,8 +5345,6 @@ fi
if [ "$PLATFORM_MAC" = "yes" ] && [ "$QT_CROSS_COMPILE" = "no" ]; then
if [ "$CFG_RPATH" = "yes" ]; then
QMAKE_CONFIG="$QMAKE_CONFIG absolute_library_soname"
# set the default rpath to the library installation directory
RPATH_FLAGS="\"$QT_INSTALL_LIBS\" $RPATH_FLAGS"
fi
elif [ -z "`getXQMakeConf 'QMAKE_(LFLAGS_)?RPATH'`" ]; then
if [ -n "$RPATH_FLAGS" ]; then
@ -5360,15 +5358,14 @@ elif [ -z "`getXQMakeConf 'QMAKE_(LFLAGS_)?RPATH'`" ]; then
CFG_RPATH=no
fi
else
if [ "$CFG_RPATH" = "yes" ]; then
# set the default rpath to the library installation directory
RPATH_FLAGS="\"$QT_INSTALL_LIBS\" $RPATH_FLAGS"
fi
if [ -n "$RPATH_FLAGS" ]; then
# add the user defined rpaths
QMakeVar add QMAKE_RPATHDIR "$RPATH_FLAGS"
fi
fi
if [ "$CFG_RPATH" = "yes" ]; then
QT_CONFIG="$QT_CONFIG rpath"
fi
if [ '!' -z "$I_FLAGS" ]; then
# add the user define include paths

View File

@ -94,6 +94,12 @@ defineTest(qtAddModule) {
isEmpty(lib): lib = -l$${MODULE_NAME}$${QT_LIBINFIX}
LINKAGE += $$lib
contains(QT_CONFIG, rpath) {
rpath = $$eval(QT.$${MODULE}.rpath)
isEmpty(rpath): rpath = $$MODULE_LIBS
QMAKE_RPATHDIR *= $$rpath
}
# Make sure we can link to uninstalled libraries
unix:!mac:!isEmpty(QT.$${1}.libs) { # Use unmodified path, so /usr/lib also works
for(rpl, QT.$${1}.rpath_link): \
@ -120,6 +126,7 @@ defineTest(qtAddModule) {
export(QMAKE_FRAMEWORKPATH)
export(QMAKE_LFLAGS)
export(QMAKE_LIBDIR)
export(QMAKE_RPATHDIR)
return(true)
}

View File

@ -11,6 +11,8 @@
# Permit modules to enforce being built outside QTDIR.
force_independent: mod_component_base = $$MODULE_BASE_OUTDIR
isEmpty(MODULE_INSTALL_LIBS): MODULE_INSTALL_LIBS = $$[QT_INSTALL_LIBS]
MODULE_FWD_PRI = $$mod_qmake_base/mkspecs/modules/qt_$${MODULE}.pri
# -rpath-link is used by the linker to find depedencies of dynamic
@ -64,6 +66,7 @@
"QT_MODULE_PLUGIN_BASE = $$mod_component_base/plugins" \
$$module_rpathlink \
$$module_rpathlink_priv \
"QT.$${MODULE}.rpath = $$MODULE_INSTALL_LIBS" \
"include($$MODULE_PRI)"
write_file($$MODULE_FWD_PRI, MODULE_FWD_PRI_CONT)|error("Aborting.")
touch($$MODULE_FWD_PRI, $$MODULE_PRI)

View File

@ -2534,7 +2534,7 @@ void Configure::generateOutputVars()
// Directories and settings for .qmake.cache --------------------
if (dictionary.contains("XQMAKESPEC") && dictionary[ "XQMAKESPEC" ].startsWith("linux"))
dictionary[ "QMAKE_RPATHDIR" ] = dictionary[ "QT_INSTALL_LIBS" ];
qtConfig += "rpath";
qmakeVars += QString("OBJECTS_DIR = ") + formatPath("tmp/obj/" + dictionary["QMAKE_OUTDIR"]);
qmakeVars += QString("MOC_DIR = ") + formatPath("tmp/moc/" + dictionary["QMAKE_OUTDIR"]);