[Qt-interest] QMake hack to create compile-tme 'build version' string

Joseph Crowell joseph.w.crowell at gmail.com
Mon Oct 17 23:38:30 CEST 2011


On 10/17/2011 8:38 AM, Bill Crocker wrote:
> Syam Krishnan wrote:
>>    Hi..
>>
>>    I would like my Qt application display a 'build version'  that changes
>> every time it's compiled. i.e. the string should identify a unique build
>> of the executable.
>> I want to display this version string when the user invokes the 'About'
>> box for the application. My idea of such a build version is a string
>> that represents the time at which the build was done. For example,
>> something like: "201110171900" (ignoring seconds).
>>
>> In another project with hand-made Makefile, I'm doing this with a make
>> rule for auto-generating a header file that has such a pre-processor macro.
>>
>> Can anything similar be done with QMake? I tried the manuals, but
>> couldn't find anything that would help me here. Any number/string that
>> uniquely identifies the build will be sufficient.
>>
> I use the QMAKE_PRE_LINK and QMAKE_POST_LINK options to do this.
>
>> Regards,
>>
>> Syam
>>
Here is an example using mercurial. 
http://qtcreator.blogspot.com/2010/05/code-to-generate-version-number-header.html 
A member of one of my projects has successfully modified this for use on 
Subversion. It worked quite well once we got it going right.



More information about the Qt-interest-old mailing list