Hello,

Le Sun, 05 Jun 2011 11:02:00 +0200,
Quintus <sutn...@gmx.net> a écrit :

> I'm working on a git-versioned project that I'd like to display it's
> version number for development versions like this:
> 
> 1.2.3-dev (commit abc1234 on devel, 12/4/10)

For  similar need I did something like :

execute_process(COMMAND sh ../getlocalversion OUTPUT_VARIABLE MYPROG_VERSION)
add_definitions(-DMYPROG_VERSION="${MYPROG_VERSION}")

where getlocalversion is a shell script that does :

printf "%s%s" $(git rev-parse --verify --short HEAD) $(if test `git
diff-index --name-only HEAD | wc -l` -ne 0 ; then echo "-dirty"; fi)

However, I am not very happy with this, because the version is
determined at configuration time, and not at compile time. Therefore,
if I make some changes and commit them to the Git repository without
re-doing the CMake configuration step, the program version isn't
changed. Any idea on how to make sure that the version of the program
is updated at every compilation ?

Thanks,

Thomas
-- 
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to