From 4f2a571f0969eec6178e0bc8723b60cc05443d20 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 18 Jan 2017 14:46:35 +0100 Subject: [PATCH] fix usage of "empty" libraries a header-only library in a default location would produce no variables at all, making it appear undefined. fix this by forcing the writeout of the QMAKE_LIBS_* variable, and use its definedness (rather than non-emptiness) as a signifier. this works for both QMAKE_USE and configure tests'/libraries' 'use' entries. Change-Id: Id7a1e23725caba1a91ea4db448b4aeb7fe632393 Reviewed-by: Lars Knoll --- mkspecs/features/qmake_use.prf | 22 ++++++++-------------- mkspecs/features/qt_configure.prf | 9 +++------ mkspecs/features/qt_helper_lib.prf | 1 + mkspecs/features/qt_module_pris.prf | 2 +- 4 files changed, 13 insertions(+), 21 deletions(-) diff --git a/mkspecs/features/qmake_use.prf b/mkspecs/features/qmake_use.prf index 9b6c67ccc2..f81d1cece4 100644 --- a/mkspecs/features/qmake_use.prf +++ b/mkspecs/features/qmake_use.prf @@ -5,25 +5,19 @@ for(ever) { use = $$split(use, /) name = $$take_first(use) nu = $$upper($$name) - debug: \ - libs = $$eval(QMAKE_LIBS_$${nu}_DEBUG) - else: \ - libs = $$eval(QMAKE_LIBS_$${nu}_RELEASE) - libs += $$eval(QMAKE_LIBS_$$nu) - libdir = $$eval(QMAKE_LIBDIR_$$nu) - defines = $$eval(QMAKE_DEFINES_$${nu}) - includes = $$eval(QMAKE_INCDIR_$${nu}) - - isEmpty(libs):isEmpty(defines):isEmpty(includes): \ + !defined(QMAKE_LIBS_$$nu, var): \ error("Library '$$name' is not defined.") !contains(use, nolink) { - QMAKE_LIBDIR += $$libdir - LIBS$${suffix} += $$libs + QMAKE_LIBDIR += $$eval(QMAKE_LIBDIR_$$nu) + debug: \ + LIBS$${suffix} += $$eval(QMAKE_LIBS_$${nu}_DEBUG) $$eval(QMAKE_LIBS_$$nu) + else: \ + LIBS$${suffix} += $$eval(QMAKE_LIBS_$${nu}_RELEASE) $$eval(QMAKE_LIBS_$$nu) } !contains(use, linkonly) { - DEFINES += $$defines - INCLUDEPATH += $$includes + DEFINES += $$eval(QMAKE_DEFINES_$${nu}) + INCLUDEPATH += $$eval(QMAKE_INCDIR_$${nu}) } } !isEmpty(suffix): break() diff --git a/mkspecs/features/qt_configure.prf b/mkspecs/features/qt_configure.prf index 69203abf07..b1c8d5b33a 100644 --- a/mkspecs/features/qt_configure.prf +++ b/mkspecs/features/qt_configure.prf @@ -603,7 +603,8 @@ defineTest(qtConfExportLibrary) { qtConfAddNote("Dropped compiler flags '$$ignored' when detecting library '$$name'.") NAME = $$upper($$name) - !isEmpty(libs): qtConfOutputVar(assign, $$output, QMAKE_LIBS_$$NAME, $$libs) + # LIBS is emitted even if empty, as this allows the library to be "seen". + qtConfOutputVar(assign, $$output, QMAKE_LIBS_$$NAME, $$libs) for (b, $${spfx}.builds._KEYS_): \ qtConfOutputVar(assign, $$output, QMAKE_LIBS_$${NAME}_$$upper($$b), \ $$eval($${spfx}.builds.$${b})) @@ -707,11 +708,7 @@ defineTest(qtConfTestPrepare_compile) { } isEmpty(libConfig) { nu = $$upper($$u) - libs = $$eval(QMAKE_LIBS_$$nu) $$eval(QMAKE_LIBS_$${nu}_DEBUG) $$eval(QMAKE_LIBS_$${nu}_RELEASE) - defines = $$eval(QMAKE_DEFINES_$${nu}) - includes = $$eval(QMAKE_INCDIR_$${nu}) - - isEmpty(libs):isEmpty(defines):isEmpty(includes): \ + !defined(QMAKE_LIBS_$$nu, var): \ error("Test $$1 tries to use undeclared library '$$u'") $${1}.literal_args += $$system_quote(QMAKE_USE += $$u) } else { diff --git a/mkspecs/features/qt_helper_lib.prf b/mkspecs/features/qt_helper_lib.prf index 99ba0c6877..b3e49e4626 100644 --- a/mkspecs/features/qt_helper_lib.prf +++ b/mkspecs/features/qt_helper_lib.prf @@ -42,6 +42,7 @@ THE_TARGET = $$qt5LibraryTarget($$TARGET) darwin: MODULE_DEBUG_LIBS = -L$$DESTDIR -l$${TARGET}_debug MODULE_RELEASE_LIBS = -L$$DESTDIR -l$$TARGET MODULE_PRI_CONT += \ + "QMAKE_LIBS_$${ucmodule} =" \ # Needed for the module to be recognized. "QMAKE_LIBS_$${ucmodule}_DEBUG = $$val_escape(MODULE_DEBUG_LIBS)" \ "QMAKE_LIBS_$${ucmodule}_RELEASE = $$val_escape(MODULE_RELEASE_LIBS)" } else { diff --git a/mkspecs/features/qt_module_pris.prf b/mkspecs/features/qt_module_pris.prf index 57160d11eb..bcaac230ec 100644 --- a/mkspecs/features/qt_module_pris.prf +++ b/mkspecs/features/qt_module_pris.prf @@ -59,7 +59,7 @@ defineReplace(qtExportLibsForModule) { QMAKE_LIBS_$$NAME QMAKE_LIBS_$${NAME}_DEBUG QMAKE_LIBS_$${NAME}_RELEASE \ QMAKE_DEFINES_$$NAME QMAKE_INCDIR_$$NAME for (var, vars) { - !isEmpty($$var): \ + defined($$var, var): \ result += "$$var = $$val_escape($$var)" } }