[CMake] [SUBVERSION] Retrieve details of your working copy

Tristan Carel tristan.carel at gmail.com
Thu Oct 26 11:36:33 EDT 2006


Hi CMake lovers,

svn:keywords file property is a useful subversion feature because you
can benefit in your source files the precious information known by
subversion about your project. These information are filled and
maintained automagically by subversion.
(details here http://svnbook.red-bean.com/nightly/en/svn.advanced.props.html#svn.advanced.props.special.keywords)

But I needed these information to be known by a higher process, I mean CMake.
I had the following requirements on a project:
- I wanted the repository revision number be part of the software
version I mean CPACK_PACKAGE_VERSION
- But I needed to use information about the repository (revision, url,
...) in files generated by CMake (for example to generate a Doxygen
configuration file whose title contains the project revision and the
repository url.)

So I've written UseSubversion.cmake which extract details from the
command `svn info'.

Here is the documentation of the file you can find in attachment:

# - Extract information from a subversion repository
# The module defines the following variables:
# SUBVERSION_SVN_EXECUTABLE - path to the subversion command line client
# SUBVERSION_VERSION_SVN - version of the subversion command line client
#
# The module defines the following macros:
# SUBVERSION_REPOSITORY(<DIR>): extract information of a subversion
#                               working copy at location <DIR>
#   It defines the following variables:
#   SUBVERSION_REPO_URL - url of the repository (at location <DIR>)
#   SUBVERSION_REPO_ROOT - root url of the repository
#   SUBVERSION_REPO_REVISION - current revision
#   SUBVERSION_REPO_LAST_CHANGED_AUTHOR - author of last commit
#   SUBVERSION_REPO_LAST_CHANGED_DATE - date of last commit
#   SUBVERSION_REPO_LAST_CHANGED_REV - revision of last commit
#   SUBVERSION_REPO_INFOS - output of command `svn info <DIR>'
#


To use it:
### Extract information from the current subversion working copy
INCLUDE(UseSubversion.cmake)
IF(SUBVERSION_SVN_FOUND)
  SUBVERSION_REPOSITORY(${PROJECT_SOURCE_DIR})
ENDIF(SUBVERSION_SVN_FOUND)


There are very few features but it fullfils my expectations. For those
who are interested, I guess features provided by this module can be
extended relative to your needs. So if you see something that could be
added, just tell us. (for example the log of the last checkin: output
of the command `svn log -r COMMITTED')

@Maintainers: is there some ugly pieces of code? is it worth to add
this file to the wiki?

CU
-- 
Tristan Carel
Music with dinner is an insult both to the cook and the violinist.
http://tristan-carel.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: UseSubversion.cmake
Type: application/octet-stream
Size: 4283 bytes
Desc: not available
Url : http://public.kitware.com/pipermail/cmake/attachments/20061026/a68e59bd/UseSubversion.obj


More information about the CMake mailing list