From 86f64a46133c6aac846d49e1b4015046e037e0ae Mon Sep 17 00:00:00 2001 From: Ivan Belyakov Date: Mon, 26 Dec 2022 12:22:25 +0300 Subject: [PATCH] fix: build issue caused by pkgconfig and system-wide QT. Avoid using QTDIR env and hardcoded subdirectories. Use 'qmake' to detect paths to lib, qml, etc. It fixes build on hosts with multiple QT installations, where one of them is installed system-wide. --- Makefile | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index f048e13644..bebca928db 100644 --- a/Makefile +++ b/Makefile @@ -93,8 +93,8 @@ endif check-qt-dir: -ifeq ($(QTDIR),) - $(error Cannot find your Qt5 installation. Please run "$(MAKE) QTDIR=/path/to/your/Qt5/installation/prefix ...") +ifeq ($(shell qmake -v 2>/dev/null),) + $(error Cannot find your Qt5 installation. Please make sure to export correct Qt installation binaries path to PATH env) endif check-pkg-target-linux: @@ -149,11 +149,14 @@ endif # Qt5 dirs (we can't indent with tabs here) ifneq ($(detected_OS),Windows) - QT5_PCFILEDIR := $(shell pkg-config --variable=pcfiledir Qt5Core 2>/dev/null) - QT5_LIBDIR := $(shell pkg-config --variable=libdir Qt5Core 2>/dev/null) - ifeq ($(QT5_PCFILEDIR),) - QT5_PCFILEDIR := $(QTDIR)/lib/pkgconfig - QT5_LIBDIR := $(QTDIR)/lib + QT5_LIBDIR := $(shell qmake -query QT_INSTALL_LIBS 2>/dev/null) + QT5_QMLDIR := $(shell qmake -query QT_INSTALL_QML 2>/dev/null) + QT5_INSTALL_PREFIX := $(shell qmake -query QT_INSTALL_PREFIX 2>/dev/null) + QT5_PKGCONFIG_INSTALL_PREFIX := $(shell pkg-config --variable=prefix Qt5Core 2>/dev/null) + ifeq ($(QT5_INSTALL_PREFIX),$(QT5_PKGCONFIG_INSTALL_PREFIX)) + QT5_PCFILEDIR := $(shell pkg-config --variable=pcfiledir Qt5Core 2>/dev/null) + else + QT5_PCFILEDIR := $(QT5_LIBDIR)/pkgconfig # some manually installed Qt5 instances have wrong paths in their *.pc files, so we pass the right one to the linker here ifeq ($(detected_OS),Darwin) NIM_PARAMS += -L:"-framework Foundation -framework AppKit -framework Security -framework IOKit -framework CoreServices -framework LocalAuthentication" @@ -441,7 +444,7 @@ $(STATUS_CLIENT_APPIMAGE): nim_status_client $(APPIMAGE_TOOL) nim-status.desktop cp $(STATUSKEYCARDGO) tmp/linux/dist/usr/lib/ echo -e $(BUILD_MSG) "AppImage" - linuxdeployqt tmp/linux/dist/nim-status.desktop -no-copy-copyright-files -qmldir=ui -qmlimport=$(QTDIR)/qml -bundle-non-qt-libs + linuxdeployqt tmp/linux/dist/nim-status.desktop -no-copy-copyright-files -qmldir=ui -qmlimport=$(QT5_QMLDIR) -bundle-non-qt-libs # Qt plugins cp $(FCITX5_QT) tmp/linux/dist/usr/plugins/platforminputcontexts/