Version Numbers in a project with Qt

前端 未结 2 729
无人共我
无人共我 2021-01-04 04:27

Version numbers are needed all over a project; in installers, code, toolchains etc. I despise duplication. I want my version numbers to be stored in one central authoritativ

2条回答
  •  星月不相逢
    2021-01-04 05:09

    I use something like this in my build system

    #.pro file
    #Application version
    VERSION_MAJOR = 1
    VERSION_MINOR = 0
    VERSION_BUILD = 0
    
    DEFINES += "VERSION_MAJOR=$$VERSION_MAJOR"\
           "VERSION_MINOR=$$VERSION_MINOR"\
           "VERSION_BUILD=$$VERSION_BUILD"
    
    #Target version
    VERSION = $${VERSION_MAJOR}.$${VERSION_MINOR}.$${VERSION_BUILD}
    

    And after that you can use VERSION_MAJOR and others as normal macro in your application.

提交回复
热议问题