You can have automatic version numbering for libraries built using QMake. Consider the following example using SVN to get the current version (substitute it with a command that returns the version number for your project).
Add the following to your project file:
VERSION = $$system(svn info -r HEAD . | grep 'Changed\ Rev' | cut -b 19-)
!isEmpty(VERSION){
VERSION = 0.$${VERSION}
}
You can also set a version for your application by adding:
VERSTR = '\\"$${VERSION}\\"' # place quotes around the version string
DEFINES += VER=\"$${VERSTR}\" # create a VER macro containing the version string
Then you can use the "VER" macro in your application to obtain the quoted version number:
#include <stdio.h>
int main(){
printf("VERSION: %s\n", VER);
return 0;
}
VERSION = $$system(svn info -r HEAD . | grep 'Changed\ Rev' | cut -b 19-)
!isEmpty(VERSION){
VERSION = 0.$${VERSION}
}
VERSTR = '\\"$${VERSION}\\"'
DEFINES += VER=\"$${VERSTR}\"