View Full Version : Qt version checking at the project-file
roxton
14th August 2008, 19:05
Hello! How I can to check the Qt version dependency at the .pro-file?
In the pseudocode, I need something like this:
if (QT_VERSION < 4.4)
{
show some message; abort configuration;
}
spirit
14th August 2008, 19:14
read this
http://doc.trolltech.com/4.4/qmake-variable-reference.html#qt-version
http://doc.trolltech.com/4.4/qmake-function-reference.html#contains-variablename-value
contains(QT_VERSION, 4.4.1) {
message(4.4.1)
}
jpn
14th August 2008, 19:47
This is how we do it in LibQxt project:
#check Qt version
QT_VERSION = $$[QT_VERSION]
QT_VERSION = $$split(QT_VERSION, ".")
QT_VER_MAJ = $$member(QT_VERSION, 0)
QT_VER_MIN = $$member(QT_VERSION, 1)
lessThan(QT_VER_MAJ, 4) | lessThan(QT_VER_MIN, 2) {
error(LibQxt requires Qt 4.2 or newer but Qt $$[QT_VERSION] was detected.)
}
It would be nice if there was a built-in version check function in qmake...
roxton
15th August 2008, 10:50
Thanks a lot!
cth35
27th June 2013, 15:24
This is how we do it in LibQxt project:
#check Qt version
QT_VERSION = $$[QT_VERSION]
QT_VERSION = $$split(QT_VERSION, ".")
QT_VER_MAJ = $$member(QT_VERSION, 0)
QT_VER_MIN = $$member(QT_VERSION, 1)
lessThan(QT_VER_MAJ, 4) | lessThan(QT_VER_MIN, 2) {
error(LibQxt requires Qt 4.2 or newer but Qt $$[QT_VERSION] was detected.)
}
It would be nice if there was a built-in version check function in qmake...
Humm the code above will display the message for a 5.0 version also no ?
ChrisW67
27th June 2013, 23:43
Yes, but that code is from 2008 when there was no Qt5 only Qt3 and Qt4. LibQxt no longer checks to exclude Qt3.
For Qt4+ you can just:
greaterThan(QT_MAJOR_VERSION, 4) {
}
equals(QT_MAJOR_VERSION, 5) {
}
# or more complex stuff like
equals(QT_MAJOR_VERSION, 4):lessThan(QT_MINOR_VERSION, 8) {
}
QT_MAJOR_VERSION, QT_MINOR_VERSION, and QT_PATCH_VERSION are defined for you.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.