Update qmake version check for Qt 5.9 and Qt 6

The old way to check for the Qt version was a bit of a hack
and not very flexible. For Qt 6, it was broken and produced
false positives.

This commit fixes this by replacing the check function with
a proper implementation imported from QtCreator's qmake files
and updates the minimum requirements to reflect the new situation.
This commit is contained in:
Felix Kauselmann 2021-03-12 17:01:42 +01:00
parent 0925771f05
commit 14d9ba9de5

View File

@ -8,16 +8,35 @@ unix:QMAKE_CXXFLAGS_RELEASE += -DNDEBUG
win32:QMAKE_CXXFLAGS_RELEASE += /DNDEBUG win32:QMAKE_CXXFLAGS_RELEASE += /DNDEBUG
# check Qt version # check Qt version
QT_VERSION = $$[QT_VERSION] defineTest(minQtVersion) {
QT_VERSION = $$split(QT_VERSION, ".") maj = $$1
QT_VER_MAJ = $$member(QT_VERSION, 0) min = $$2
QT_VER_MIN = $$member(QT_VERSION, 1) patch = $$3
isEqual(QT_MAJOR_VERSION, $$maj) {
lessThan(QT_VER_MAJ, 5) { isEqual(QT_MINOR_VERSION, $$min) {
error(YACReader requires Qt 5 or newer but Qt $$[QT_VERSION] was detected.) isEqual(QT_PATCH_VERSION, $$patch) {
return(true)
} }
lessThan(QT_VER_MIN, 6):!CONFIG(no_opengl) { greaterThan(QT_PATCH_VERSION, $$patch) {
error ("You need at least Qt 5.6 to compile YACReader or YACReaderLibrary.") return(true)
}
}
greaterThan(QT_MINOR_VERSION, $$min) {
return(true)
}
}
greaterThan(QT_MAJOR_VERSION, $$maj) {
return(true)
}
return(false)
}
!minQtVersion(5, 9, 0) {
error(YACReader requires Qt 5.9 or newer but $$[QT_VERSION] was detected)
}
minQtVersion(6, 0, 0) {
error(YACReader does not support building with Qt6 (yet))
} }
# reduce log pollution # reduce log pollution