Search code examples
qtqt-creatorqmakemacos-mojave

Specify minimum Qt version for QtCreator / QMake build


I have a Qt project previously built using Qt 5.11. In order to support MacOS Mojave's Dark Mode, I have updated the build to use Qt 5.13.2. This works perfectly, but the kit version is stored locally in the session settings not with the .pro project file.

I wish to enforce a minimum Qt kit version for the build, so that the build will abort if the correct kit version is not selected, ideally in the .pro file rather then the source code. How can I do that?


Solution

  • using versionAtLeast or lessThan you can check the Qt version. For instance:

    equals(QT_MAJOR_VERSION, 5):lessThan(QT_MINOR_VERSION, 12) {
        message("Cannot use Qt $${QT_VERSION}")
        error("Use Qt 5.12 or newer")
    }
    

    or better:

    !versionAtLeast(QT_VERSION, 5.12.0) {
        message("Cannot use Qt $${QT_VERSION}")
        error("Use Qt 5.12 or newer")
    }