PDA

View Full Version : Qt(Creator), subversion: include revision



rgrayson
8th May 2009, 16:39
Qt 2009.01 (4.5)

I'm trying to automatically include the revision number in a build of a Qt project, specifically with Qt Creator. I.E. I want to include a label in an About dialog that shows what build number the executable is from. My head is about to explode, I've tried so many things.

I know about 'svnversion .' I'm trying to make it play nicely with qmake and/or the .pro file, without success. The subversion faq says:

##
## To use this, in yourfile.c do something like this:
## printf("this program was compiled from SVN revision %s\n",SVN_REV);
##

SVNDEF := -D'SVN_REV="$(shell svnversion -n .)"'
CFLAGS := $(SVNDEF) ... continue with your other flags ...

But I can't put that in the .pro file. I did find an old thread where someone said to put this in a .pro file:

# Subversion revisions
QMAKE_EXTRA_TARGETS += revtarget
PRE_TARGETDEPS += version.h
revtarget.target = version.h
revtarget.commands = @echo "const char *revision = \"$(shell svnversion .)\";" > $$revtarget.target
revtarget.depends = $$SOURCES $$HEADERS $$FORMS

But that also doesn't work. The command `svnversion .` never actually gets executed (QtCreator output says 'CreateProcess failed(null,svnversion...'), and the version.h file is only written if it previously didn't exist.

Any help would be appreciated. It seems this should be a simple task. Maybe I'm making it more complicated than it is?