In my setup, I want to support both system-wide Qt installations and custom Qt installations. I can use pkg-config to get the correct compile and link flags for my system-wide installation:
CONFIG += link_pkgconfig
PKGCONFIG += Qt5Core
However, if pkg-config cannot find Qt5Core, the build will fail with Project ERROR: Qt5Core development package not found.
Instead of failing, I want to set reasonable defaults (e.g. /usr/local/qt5). It should achieve the following:
if pkg-config can find Qt5Core {
PKGCONFIG += Qt5Core
} else {
INCLUDEPATH += /usr/local/qt5/
LIBS += -lQt5Core
}
How can I accomplish this in my project configuration?
There is a qmake function for this: http://doc.qt.io/qt-5/qmake-test-function-reference.html#packagesexist-packages
packagesExist(Qt5Core) {
PKGCONFIG += Qt5Core
} else {
INCLUDEPATH += /usr/local/qt5/
LIBS += -lQt5Core
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With