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.
This commit is contained in:
Ivan Belyakov 2022-12-26 12:22:25 +03:00 committed by IvanBelyakoff
parent 821c1f0ba0
commit 86f64a4613
1 changed files with 11 additions and 8 deletions

View File

@ -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/