[CMake] Portable revision lookup?

Oliver kfsone Smith osmith at playnet.com
Thu Feb 2 17:41:07 EST 2012


Oliver kfsone Smith said the following on 2/2/2012 4:17 PM:
> John Drescher said the following on 2/2/2012 3:36 PM:
>> Cmake has support for pulling the svn and I believe git revs using
>> cmake modules. Here is what I do for svn
>>
> Much appreciated -- I just didn't think to look in the "Find" package, 
> duly noted for future reference.
>
> - Oliver
Hrm - ran into a problem with that, the revision is only produced when 
cmake rolls the Makefiles. I.e, if you do the following:

$ cd /tmp && mkdir cmake-test && cd cmake-test && svnadmin create repo 
&& svn co file:///tmp/cmake-test/repo src || echo "Failed"
$ cat >CMakeLists.txt <<END_CMAKE
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(Test)
FIND_PACKAGE(Subversion REQUIRED)

MESSAGE("Checking SVN Info of ${Test_SOURCE_DIR} -> Repo")
Subversion_WC_INFO(${Test_SOURCE_DIR} Repo)
MESSAGE("Repo_WC_REVISION = ${Repo_WC_REVISION}")
$ cmake -G "Unix Makefiles" .
...
$ make
...
/Repo_WC_REVISION=0/
$ svn add CMakeLists.txt && svn commit -m "Bump to revision 1" && svn update
...
/At revision 1./
$ make
/Repo_WC_REVISION=0/

In particular, this prevents me using it to generate CPack package names :(

- Oliver





More information about the CMake mailing list