Search code examples
qtqmake

qmake math operation (qt increment build number)


I am trying to to add build increment mechanism within .pro file.

To do so I have created a file named "version" with this content "1.1.15" (MAJOR_VERSION.MINOR_VERSION.BUILD_NUMBER)

Please find here my .pro content

MY_VERSION = "$$cat(version)"

VERSIONS = $$split(MY_VERSION, ".")

VERSION_MAJ = $$member(VERSIONS, 0)
VERSION_MIN = $$member(VERSIONS, 1)
VERSION_BUILD = $$member(VERSIONS, 2)

# VERSION_BUILD++ ??? HOW TO ???

VERSIONS = $$VERSION_MAJ $$VERSION_MIN $$VERSION_BUILD
MY_VERSION = $$join(VERSIONS, ".")

write_file(version, MY_VERSION)

Could someone help me on this ?


Solution

  • I've found a solution (not clean for me)

    win32 {
        VERSION_BUILD = $$system("set /a $$VERSION_BUILD + 1")
    } else:unix {
        VERSION_BUILD = $$system("echo $(($$VERSION_BUILD + 1))")
    }