From 0239b4f21705af3c47ebfda34fa354ecc865c52d Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 27 Oct 2016 15:43:08 +0200 Subject: decouple packageExists() and PKGCONFIG from qt configuration users may want to use pkg-config regardless of whether qt itself was built with it. that's particularly relevant when using binary packages on macos while trying to use 3rd party dependencies from homebrew. Task-number: QTBUG-36256 Change-Id: I15e6d0bf5cdaff4274e2d7c07917e97f29157a5c Reviewed-by: Massimo Callegari Reviewed-by: Lars Knoll --- mkspecs/features/qt_functions.prf | 62 +++++++++++++++++++++++++++++++-------- 1 file changed, 49 insertions(+), 13 deletions(-) (limited to 'mkspecs/features/qt_functions.prf') diff --git a/mkspecs/features/qt_functions.prf b/mkspecs/features/qt_functions.prf index 708815d9f9..999cd18154 100644 --- a/mkspecs/features/qt_functions.prf +++ b/mkspecs/features/qt_functions.prf @@ -235,17 +235,58 @@ defineTest(qtAddTargetEnv) { defineReplace(pkgConfigExecutable) { isEmpty(PKG_CONFIG) { - !isEmpty(QMAKE_PKG_CONFIG): \ + !isEmpty(QMAKE_PKG_CONFIG) { + # Assumed to be properly sysrootified. PKG_CONFIG = $$QMAKE_PKG_CONFIG - else: \ + export(PKG_CONFIG) + } else { PKG_CONFIG = pkg-config + !cross_compile { + export(PKG_CONFIG) + } else { + # Cross compiling, ensure that pkg-config is set up sanely. + sysroot = $$[QT_SYSROOT] + + pkgConfigLibdir = $$(PKG_CONFIG_LIBDIR) + isEmpty(pkgConfigLibdir) { + isEmpty(sysroot) { + warning("Cross compiling without sysroot. Disabling pkg-config.") + return() + } + !exists("$$sysroot/usr/lib/pkgconfig") { + warning("Disabling pkg-config since PKG_CONFIG_LIBDIR is not set and the") + warning("host's .pc files would be used (even if you set PKG_CONFIG_PATH).") + warning("Set this variable to the directory that contains target .pc files") + warning("for pkg-config to function correctly when cross-compiling.") + return() + } + + pkgConfigLibdir = $$system_path($$sysroot/usr/lib/pkgconfig)$$QMAKE_DIRLIST_SEP$$system_path($$sysroot/usr/share/pkgconfig) + !isEmpty(GCC_MACHINE_DUMP): \ + pkgConfigLibdir = "$$pkgConfigLibdir$$QMAKE_DIRLIST_SEP$$system_path($$sysroot/usr/lib/$$GCC_MACHINE_DUMP/pkgconfig)" + message("PKG_CONFIG_LIBDIR automatically set to $$pkgConfigLibdir") + } + pkgConfigSysrootDir = $$(PKG_CONFIG_SYSROOT_DIR) + isEmpty(pkgConfigSysrootDir) { + isEmpty(sysroot) { + warning("Disabling pkg-config since PKG_CONFIG_SYSROOT_DIR is not set.") + warning("Set this variable to your sysroot for pkg-config to function") + warning("correctly when cross-compiling.") + return() + } - sysroot.name = PKG_CONFIG_SYSROOT_DIR - sysroot.value = $$PKG_CONFIG_SYSROOT_DIR - libdir.name = PKG_CONFIG_LIBDIR - libdir.value = $$PKG_CONFIG_LIBDIR - QT_TOOL_NAME = pkg-config - qtAddToolEnv(PKG_CONFIG, sysroot libdir, SYS) + pkgConfigSysrootDir = $$sysroot + message("PKG_CONFIG_SYSROOT_DIR automatically set to $$pkgConfigSysrootDir") + } + + sysroot.name = PKG_CONFIG_SYSROOT_DIR + sysroot.value = $$pkgConfigSysrootDir + libdir.name = PKG_CONFIG_LIBDIR + libdir.value = $$pkgConfigLibdir + QT_TOOL_NAME = pkg-config + qtAddToolEnv(PKG_CONFIG, sysroot libdir, SYS) + } + } } equals(QMAKE_HOST.os, Windows): \ @@ -257,11 +298,6 @@ defineReplace(pkgConfigExecutable) { } defineTest(packagesExist) { - !qtConfig(pkg-config) { - warning("pkg-config disabled, can't check package existence") - return(false) - } - # this can't be done in global scope here because qt_functions is loaded # before the .pro is parsed, so if the .pro set PKG_CONFIG, we wouldn't know it # yet. oops. -- cgit v1.2.3