From e2446afaa10ddd365d8de834d3fb1d00fd661355 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Thu, 23 Feb 2023 15:50:23 +0100 Subject: 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. Pick-to: 6.5 6.5.0 Task-number: QTBUG-110356 Change-Id: Icee67fc01313a6c6f34178a6345ccae1b57429d7 Reviewed-by: Qt CI Bot Reviewed-by: Joerg Bornemann --- mkspecs/features/qt.prf | 9 +++++++-- mkspecs/features/qt_functions.prf | 8 ++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) (limited to 'mkspecs/features') 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) } -- cgit v1.2.3