Version Numbers in a project with Qt

前端 未结 2 724
无人共我
无人共我 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:07

    If you want to be able to store your version numbers in a c header file, you can do so and then import them into the Qt project variables in the project file. Something like the below should work:

    Version.h:

    #define MY_MAJOR_VERSION 3
    #define MY_MINOR_VERSION 1
    

    .pro

    HEADERS  += Version.h
    
    VERSION_MAJOR = MY_MAJOR_VERSION
    VERSION_MINOR = MY_MINOR_VERSION
    

    The advantage of doing it this way round is that you can then use your authoritative header file if you need to compile other parts of the project away from Qt.

提交回复
热议问题