summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2023-02-23 15:50:23 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-03-05 06:22:38 +0000
commite230713f8cc7654bee7dddf5bb8790d9e4cc09e3 (patch)
tree228993eaceff96d623511d60cbbd0d7fe7512971
parentd5921e7376d94ad2c1199f67cb2edfffdc5641ea (diff)
downloadqtbase-e230713f8cc7654bee7dddf5bb8790d9e4cc09e3.tar.gz
qmake: Resolve target suffix based on Qt build config for static plugins
The qtPlatformTargetSuffix() function is used in various places to determine the suffix of targets based on the config, which for macOS will result in a _debug suffix in debug mode. This becomes tricky when one project built in debug mode tries to depend on the libraries/plugins of another project (Qt) built in release, as the qtPlatformTargetSuffix() function uses the current CONFIG as input, which may be different than the QT_CONFIG (or CONFIG of whatever project is being depended on). For libraries this was fixed in 50e664835bc2130e8693364641f9aaa7133b6998 by iterating all known library paths, and trying the CONFIG suffix before falling back to release version. For plugins this was never solved, which becomes an issue when linking to static plugins, either in a fully static build of Qt, or when some of the plugins are static (permission plugins e.g.). In this situation, the user project has to have the same configuration as Qt was built with, to avoid errors like: error: no such file or directory: '~/6.x-static/qtbase/plugins/platforms/libqcocoa_debug.a' To work around this, we assume that a plugin installed into the Qt tree has the same build configuration as Qt itself, then then use QT_CONFIG as the determining factor when linking to the plugin. This still ties the build config of the plugin to the config of Qt, but relaxes the relationship to the application, allowing it to be built in either debug or release, which is an improvement to the current state. Task-number: QTBUG-110356 Change-Id: Icee67fc01313a6c6f34178a6345ccae1b57429d7 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit e2446afaa10ddd365d8de834d3fb1d00fd661355) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--mkspecs/features/qt.prf9
-rw-r--r--mkspecs/features/qt_functions.prf8
2 files changed, 13 insertions, 4 deletions
diff --git a/mkspecs/features/qt.prf b/mkspecs/features/qt.prf
index d8a8627d83..3c4b284b68 100644
--- a/mkspecs/features/qt.prf
+++ b/mkspecs/features/qt.prf
@@ -156,13 +156,18 @@ import_plugins {
# the plugin path. Unknown plugins must rely on the default link path.
plug_type = $$eval(QT_PLUGIN.$${plug}.TYPE)
!isEmpty(plug_type) {
- plug_name = $$QMAKE_PREFIX_STATICLIB$${plug}$$qtPlatformTargetSuffix().$$QMAKE_EXTENSION_STATICLIB
+ # Respect target config if Qt provides both debug and release versions
+ # of each plugin. Otherwise, respect what Qt was configured with.
+ qtConfig(debug_and_release): config_variable = CONFIG
+ else: config_variable = QT_CONFIG
+
+ plug_name = $$QMAKE_PREFIX_STATICLIB$${plug}$$qtPlatformTargetSuffix($$config_variable).$$QMAKE_EXTENSION_STATICLIB
plug_path = $$eval(QT_PLUGIN.$${plug}.PATH)
isEmpty(plug_path): \
plug_path = $$[QT_INSTALL_PLUGINS/get]
LIBS += $$plug_path/$$plug_type/$$plug_name
} else {
- LIBS += -l$${plug}$$qtPlatformTargetSuffix()
+ LIBS += -l$${plug}$$qtPlatformTargetSuffix(CONFIG)
}
}
diff --git a/mkspecs/features/qt_functions.prf b/mkspecs/features/qt_functions.prf
index dd780ad556..f1371c8cc6 100644
--- a/mkspecs/features/qt_functions.prf
+++ b/mkspecs/features/qt_functions.prf
@@ -1,9 +1,13 @@
defineReplace(qtPlatformTargetSuffix) {
+ config_variable = $$1
+ isEmpty(config_variable): \
+ config_variable = CONFIG
+
suffix =
android: return($${suffix}_$${QT_ARCH})
win32 {
- CONFIG(debug, debug|release) {
+ contains($$config_variable, debug, debug|release) {
mingw {
qtConfig(debug_and_release):build_pass: \
return($${suffix}d)
@@ -14,7 +18,7 @@ defineReplace(qtPlatformTargetSuffix) {
}
}
darwin {
- CONFIG(debug, debug|release) {
+ contains($$config_variable, debug, debug|release) {
!debug_and_release|build_pass: \
return($${suffix}_debug)
}