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

Bill Crocker william.crocker at analog.com
Wed Oct 19 15:18:25 CEST 2011


Syam Krishnan wrote:
> On 10/18/2011 01:49 PM, Manner Robert wrote:
>> You can also use something like:
>>
>> VERSION = $$system(date "+%Y%m%d%H%M")
>> DEFINES += VERSION=\\\"\"$$VERSION\"\\\"
>> message ("Version:" $$VERSION)
> There's one problem with this method. Since it's a macro, it will be 
> reflected only if I re-compile the file that uses it (or I do a complete 
> rebuild of the project). If I change some other source file and build 
> the application, the unchanged object files will all have the previous 
> value of the macro.
>

As I emailed before...
The scheme which I offered does not suffer from this ill.

   If a relink is required !!for whatever other reason!!
   the file link_time.o is created on demand !!just-in-time!!
   with the current time/date and linked with the program.

Bill

----------- repeat ------------

My QMAKE_PRE_LINK activity consists of creating one more .o
file which becomes part of the link.

     QMAKE_PRE_LINK = make link_time
     LIBS          += link_time.o

And then in my Makefile:

     link_time : always
          echo "int link_time() { return `date +%s`; }" > link_time.cc;
          gcc -c ${CCFLAGS} link_time.cc

> regards,
> 
> Syam
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at qt.nokia.com
> http://lists.qt.nokia.com/mailman/listinfo/qt-interest
> 





More information about the Qt-interest-old mailing list