diff options
author | Joerg Bornemann <joerg.bornemann@qt.io> | 2021-06-24 14:27:37 +0200 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@qt.io> | 2021-06-25 18:36:13 +0200 |
commit | 50e664835bc2130e8693364641f9aaa7133b6998 (patch) | |
tree | c3d166c020ec32499736110563b673f92ab9d83e /mkspecs | |
parent | Doc: Improve QTransform documentation (diff) | |
download | qtbase-50e664835bc2130e8693364641f9aaa7133b6998.tar.xz qtbase-50e664835bc2130e8693364641f9aaa7133b6998.zip |
Fix linking of debug projects against release Qt on Darwin platforms
Consider a release-only, non-framework Qt build on macOS. Building a
debug user project would fail, because qmake tried to link
against *_debug.dylib and *_debug.a libraries.
Building a debug user project that uses QtUiTools against a release-only
framework-build Qt posed the same problem. QMake tried to link against
the libQt5UiTools_debug.a, which does not exist.
Fix this by maintaining a list of library file candidates, and use the
first existing one (or just the first one if none exists). This favors
the library matching the user project's configuration but falls back to
the release version of the library if necessary.
Fixes: QTBUG-81251
Pick-to: 6.2
Change-Id: I8d641104718edb16500c6d6e3994e736fa5ddcf4
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'mkspecs')
-rw-r--r-- | mkspecs/features/qt.prf | 43 |
1 files changed, 25 insertions, 18 deletions
diff --git a/mkspecs/features/qt.prf b/mkspecs/features/qt.prf index 729f3ac73d..6fb657e6f2 100644 --- a/mkspecs/features/qt.prf +++ b/mkspecs/features/qt.prf @@ -218,28 +218,35 @@ for(ever) { # Linking frameworks by absolute path does not work. LIBS$$var_sfx += -framework $$framework } else { - lib = $$MODULE_MODULE$$qtPlatformTargetSuffix() + lib_bases = $$MODULE_MODULE$$qtPlatformTargetSuffix() + darwin: lib_bases *= $$MODULE_MODULE win32|contains(MODULE_CONFIG, staticlib) { - lib_missing = true - lib_extensions = $$QMAKE_EXTENSION_STATICLIB - lib_extensions *= $$QMAKE_LIB_EXTENSIONS - candidates = - for(ext, lib_extensions) { - candidate = $$MODULE_LIBS/$$QMAKE_PREFIX_STATICLIB$${lib}.$$ext - candidates += $$candidate - exists($$candidate) { - lib = $$candidate - lib_missing = false - break() - } + lib_prefix = $$MODULE_LIBS/$$QMAKE_PREFIX_STATICLIB + lib_suffixes = $$QMAKE_EXTENSION_STATICLIB + lib_suffixes *= $$QMAKE_LIB_EXTENSIONS + add_lib_to_pretargetdeps = true + } else { + lib_prefix = $$MODULE_LIBS/$$QMAKE_PREFIX_SHLIB + lib_suffixes = $$QMAKE_EXTENSION_SHLIB + add_lib_to_pretargetdeps = false + } + candidates = + for(lib_base, lib_bases) { + for(lib_suffix, lib_suffixes) { + candidates += $${lib_prefix}$${lib_base}.$${lib_suffix} } - $$lib_missing { - lib = $$first(candidates) + } + lib = + for(candidate, candidates) { + exists("$$candidate") { + lib = "$$candidate" + break() } - PRE_TARGETDEPS += $$lib - } else { - lib = $$MODULE_LIBS/$$QMAKE_PREFIX_SHLIB$${lib}.$$QMAKE_EXTENSION_SHLIB } + isEmpty(lib): \ + lib = $$first(candidates) + $$add_lib_to_pretargetdeps: \ + PRE_TARGETDEPS += $$lib LIBS$$var_sfx += $$lib } } |