[CMake] XML parsing ?

Thompson, David C dcthomp at sandia.gov
Sun Mar 12 19:03:58 EST 2006


> I am wondering if it is currently possible using CMake to
> parse an XML file...
> I would like to include the SVN revision number in the target
> name somehow, and I would need to get it from the .svn/entries
> file I guess...

Actually, you should not be parsing .svn/entries. Subversion comes
with a program named svnversion that will return the revision number of
a file or directory. You can use it from CMake like this:

######
project( BOOJUM )

find_program( SVNVERSION
  svnversion
  /usr/local/bin
  /usr/bin
)

macro( svn_repository_version DESTVAR TOPDIR )
  exec_program( ${SVNVERSION} ${TOPDIR} ARGS "." OUTPUT_VARIABLE ${DESTVAR} )
endmacro( svn_repository_version )

svn_repository_version( SVNREV ${BOOJUM_SOURCE_DIR} )

configure_file( version.h.in version.h )


######
and if version.h.in contains the line:

    #define BOOJUM_REVISION @SVNREV@

then CMake will replace @SVNREV@ with the proper number when the file
is configured.

    David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/cmake/attachments/20060312/d8a4a3a5/attachment.html


More information about the CMake mailing list