qt5base-lts/mkspecs/features/mac/default_post.prf
Adam Strzelecki e0676a954c Add rpath pointing to Qt libraries in OS X and iOS
This is triggered only when app is using Qt and Qt was built with "rpath"
configuration and project does not specify QMAKE_RPATHDIR explicitly.

Added rpath is made relative to app binary location if target path lies inside
Qt SDK, so all SDK bundled tools and examples will work automatically without
any changes. Tests are an exception here, since they are being run from their
build location by CI, we may not use relative rpath that work only in install
location.

Task-number: QTBUG-31814
Change-Id: I3690f29d2b5396a19c1dbc92ad05e6c028f8515b
Reviewed-by: Jake Petroules <jake.petroules@petroules.com>
2014-11-01 19:26:12 +01:00

79 lines
3.6 KiB
Plaintext

load(default_post)
!no_objective_c:CONFIG += objective_c
qt:!isEmpty(QT_CONFIG) {
# Pick a suitable default architecture for qmake-based applications.
# If the Qt package contains one of x86 and x86_64, pick that one. If it
# contains both then use the compiler default. Make a similar decision for
# PowerPC-based systems. Note that this logic assumes that Qt has been
# configured with an architecture that is usable on the system.
contains(QMAKE_HOST.arch, ppc)|contains(QMAKE_HOST.arch, "Power Macintosh") {
!contains(QT_CONFIG, ppc64):contains(QT_CONFIG, ppc):CONFIG += ppc
contains(QT_CONFIG, ppc64):!contains(QT_CONFIG, ppc):CONFIG += ppc64
} else {
!contains(QT_CONFIG, x86_64):contains(QT_CONFIG, x86):CONFIG += x86
contains(QT_CONFIG, x86_64):!contains(QT_CONFIG, x86):CONFIG += x86_64
}
contains(QT_CONFIG, static) {
# C++11 support means using libc++ instead of libstd++. As the
# two libraries are incompatible we need to ensure the end user
# project is built using the same C++11 support/no support as Qt.
contains(QT_CONFIG, c++11) {
CONFIG += c++11
} else: c++11 {
warning("Qt was not built with C++11 enabled, disabling feature")
CONFIG -= c++11
}
!c++11 {
# Explicitly use libstdc++ if C++11 support is not enabled,
# as otherwise the compiler will choose the standard library
# based on the deployment target, which for iOS 7 and OS X 10.9
# is libc++, and we can't mix and match the two.
QMAKE_CXXFLAGS += -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 outside of Qt SDK prefix use absolute path to Qt libraries,
# otherwise make it relative, so all SDK tools and examples work when
# relocated.
# Tests are an exception, since they are launched in their build not
# install location by CI, so we cannot use relative rpaths there.
if(!contains(target.path, "$$re_escape($$[QT_INSTALL_PREFIX])/.*")|\
contains(target.path, "$$re_escape($$[QT_INSTALL_TESTS])/.*")) {
QMAKE_RPATHDIR = $$[QT_INSTALL_LIBS]
} else {
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)
}
}
}
macx-xcode:!isEmpty(QMAKE_XCODE_DEBUG_INFORMATION_FORMAT) {
debug_information_format.name = DEBUG_INFORMATION_FORMAT
debug_information_format.value = $$QMAKE_XCODE_DEBUG_INFORMATION_FORMAT
debug_information_format.build = debug
QMAKE_MAC_XCODE_SETTINGS += debug_information_format
}
cache(QMAKE_XCODE_DEVELOPER_PATH, stash)
cache(QMAKE_XCODE_VERSION, stash)
QMAKE_XCODE_LIBRARY_SUFFIX = $$qtPlatformTargetSuffix()
# Ensure that we process sdk.prf first, as it will update QMAKE_CXX
# and friends that other features/extra compilers may depend on.
sdk: load(sdk)