support -rpath for modules which are not installed to QT_INSTALL_PREFIX
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>
Thu, 9 Aug 2012 13:02:44 +0000 (15:02 +0200)
committerQt by Nokia <qt-info@nokia.com>
Sat, 11 Aug 2012 08:40:23 +0000 (10:40 +0200)
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>
configure
mkspecs/features/qt_functions.prf
mkspecs/features/qt_module_fwdpri.prf
tools/configure/configureapp.cpp

index 304136c..74d7367 100755 (executable)
--- a/configure
+++ b/configure
@@ -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
index 8daa2c4..a8f4d34 100644 (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)
 }
 
index 0f7c7c4..04d2d77 100644 (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)
index d92a323..8358a00 100644 (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"]);