Commit 967372c9 authored by Oswald Buddenhagen's avatar Oswald Buddenhagen
Browse files

sanitize qt rpath handling, in particular on mac


the addition of qt's rpath belongs into qt.prf - even on mac.
so consolidate the two implementations.
as a nice "side effect", we get relative rpaths also on linux.
another "side effect" is that we don't unnecessarily add the qt rpath to
qt modules also on linux.

the qt rpath addition mechanism should not be responsible for setting
the policy who gets a relative rpath, so move the logic to higher-level
callers.

Change-Id: I52e8fe2e8279e7b1ac25fae758867a5cb1cafcf8
Reviewed-by: default avatarJoerg Bornemann <joerg.bornemann@theqtcompany.com>
Reviewed-by: default avatarOswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
parent e853edd6
No related merge requests found
Showing with 27 additions and 27 deletions
...@@ -22,31 +22,6 @@ qt { ...@@ -22,31 +22,6 @@ qt {
QMAKE_LFLAGS += -stdlib=libstdc++ QMAKE_LFLAGS += -stdlib=libstdc++
} }
} }
# If Qt was built with shared libraries with rpath support and project does
# not specify own rpaths (including empty list) add one pointing to Qt
# libraries. This applies only to apps, since all loaded libraries inherit
# rpaths from current process executable.
else:!if(host_build:force_bootstrap):equals(TEMPLATE, app):!defined(QMAKE_RPATHDIR, var):contains(QT_CONFIG, rpath) {
# If app is expected to be installed into the Qt prefix build, use
# relative path, so all SDK tools and examples work when relocated.
prefix_build:defined(target.path, var):\
contains(target.path, "$$re_escape($$[QT_INSTALL_PREFIX])/.*"):\
# Tests are an exception, since they are launched in their build not
# install location by CI, so we cannot use relative rpaths there.
!contains(target.path, "$$re_escape($$[QT_INSTALL_TESTS])/.*") {
app_bundle {
ios: binpath = $$target.path/$${TARGET}.app
else: binpath = $$target.path/$${TARGET}.app/Contents/MacOS
} else {
binpath = $$target.path
}
QMAKE_RPATHDIR = @loader_path/$$relative_path($$[QT_INSTALL_LIBS], $$binpath)
unset(binpath)
} else {
# Otherwise, use absolute path to Qt libraries
QMAKE_RPATHDIR = $$[QT_INSTALL_LIBS]
}
}
} }
macx-xcode:!isEmpty(QMAKE_XCODE_DEBUG_INFORMATION_FORMAT) { macx-xcode:!isEmpty(QMAKE_XCODE_DEBUG_INFORMATION_FORMAT) {
......
...@@ -59,9 +59,27 @@ qt_module_deps = $$QT $$QT_PRIVATE ...@@ -59,9 +59,27 @@ qt_module_deps = $$QT $$QT_PRIVATE
qt_module_deps = $$replace(qt_module_deps, -private$, _private) qt_module_deps = $$replace(qt_module_deps, -private$, _private)
qt_module_deps = $$resolve_depends(qt_module_deps, "QT.") qt_module_deps = $$resolve_depends(qt_module_deps, "QT.")
!static:contains(QT_CONFIG, rpath):!contains(QT_CONFIG, static):!contains(QT_CONFIG, qt_framework):\ !no_qt_rpath:!static:contains(QT_CONFIG, rpath):!contains(QT_CONFIG, static):\
contains(qt_module_deps, core) { contains(qt_module_deps, core) {
QMAKE_RPATHDIR += $$[QT_INSTALL_LIBS/dev] relative_qt_rpath:defined(target.path, var) {
mac {
if(equals(TEMPLATE, app):app_bundle)|\
if(equals(TEMPLATE, lib):plugin:plugin_bundle) {
ios: binpath = $$target.path/$${TARGET}.app
else: binpath = $$target.path/$${TARGET}.app/Contents/MacOS
} else: equals(TEMPLATE, lib):!plugin:lib_bundle {
binpath = $$target.path/$${TARGET}.framework/Versions/Current
} else {
binpath = $$target.path
}
QMAKE_RPATHDIR += @loader_path/$$relative_path($$[QT_INSTALL_LIBS], $$binpath)
} else {
QMAKE_LFLAGS += -Wl,-z,origin
QMAKE_RPATHDIR += $ORIGIN/$$relative_path($$[QT_INSTALL_LIBS], $$target.path)
}
} else {
QMAKE_RPATHDIR += $$[QT_INSTALL_LIBS/dev]
}
} }
# static builds: link qml import plugins into the app. # static builds: link qml import plugins into the app.
......
...@@ -30,6 +30,7 @@ host_build:force_bootstrap { ...@@ -30,6 +30,7 @@ host_build:force_bootstrap {
} else { } else {
!build_pass:contains(QT_CONFIG, debug_and_release):contains(QT_CONFIG, build_all): CONFIG += release !build_pass:contains(QT_CONFIG, debug_and_release):contains(QT_CONFIG, build_all): CONFIG += release
target.path = $$[QT_INSTALL_BINS] target.path = $$[QT_INSTALL_BINS]
CONFIG += relative_qt_rpath # Qt's tools and apps should be relocatable
} }
INSTALLS += target INSTALLS += target
......
...@@ -101,5 +101,7 @@ probase = $$relative_path($$_PRO_FILE_PWD_, $$dirname(_QMAKE_CONF_)/examples) ...@@ -101,5 +101,7 @@ probase = $$relative_path($$_PRO_FILE_PWD_, $$dirname(_QMAKE_CONF_)/examples)
SOURCES = SOURCES =
OBJECTIVE_SOURCES = OBJECTIVE_SOURCES =
INSTALLS -= target INSTALLS -= target
} else {
CONFIG += relative_qt_rpath # Examples built as part of Qt should be relocatable
} }
} }
...@@ -42,6 +42,8 @@ host_build { ...@@ -42,6 +42,8 @@ host_build {
} }
} }
CONFIG += relative_qt_rpath # Qt libraries should be relocatable
ucmodule = $$upper($$MODULE) ucmodule = $$upper($$MODULE)
isEmpty(MODULE_INCNAME): MODULE_INCNAME = $$TARGET isEmpty(MODULE_INCNAME): MODULE_INCNAME = $$TARGET
......
...@@ -30,6 +30,8 @@ tool_plugin { ...@@ -30,6 +30,8 @@ tool_plugin {
contains(QT_CONFIG, build_all):CONFIG += build_all contains(QT_CONFIG, build_all):CONFIG += build_all
} }
CONFIG += relative_qt_rpath # Qt's plugins should be relocatable
CONFIG(static, static|shared)|prefix_build { CONFIG(static, static|shared)|prefix_build {
isEmpty(MODULE): MODULE = $$basename(TARGET) isEmpty(MODULE): MODULE = $$basename(TARGET)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment