summaryrefslogtreecommitdiffstats
path: root/mkspecs
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@qt.io>2016-10-27 15:43:08 +0200
committerOswald Buddenhagen <oswald.buddenhagen@qt.io>2016-11-01 07:56:43 +0000
commit0239b4f21705af3c47ebfda34fa354ecc865c52d (patch)
treee7cad093980c1cdd49b40675f26195b70a1d18fc /mkspecs
parent265d309cb0a423b5dd6b43a8b7354b96a0f341a1 (diff)
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 <massimocallegari@yahoo.it> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'mkspecs')
-rw-r--r--mkspecs/features/qt_functions.prf62
1 files changed, 49 insertions, 13 deletions
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.