[CMake] Version embedding - how to cause a command when make is run?

Atwood, Robert C r.atwood at imperial.ac.uk
Thu Oct 4 13:20:29 EDT 2007


 

> From: Alan W. Irwin 
> > [...]I've tried the following in CMakeLists, placing the output of
> > 'svnversion' and similar commands into an included source 
> file and it
> > works [...]
> 
> > Can some form of dependency be set so that if any source file is
> > changed [...]
> 
> > Or, should I use another way to do what I want?
> 
> One possibility is to use subversion (which presumably you 
> are using since
> you referred to svnversion) keyword functionality.
> 
> For example, if you put $Id$ into your source code comments, 

That does not work, since the comments do not go into the executable.
You have to include the $Id:$ into strings and the strings have to
actually get used or else the optimizer strips them out. I have done
that for years using CVS, which does not have  any whole-repository
revision. My approach to this was to include a little routine at the end
of each file that returns the revision string for that file, then a
routine in th main that calls all the file routines... Etc.


> 
> I haven't used svnversion myself, but it looks like all it 
> does is summarize
> revision numbers in the entire repository.  

Yes, that's the whole point! It is much easier than using individual
revision nubmers for each file  and that is one big improvement of
subversion over CVS. Think about it. The drawback is that it is only
available via that external command 'svnversion' and not as a keyword.
Back to hair tearing :-/




More information about the CMake mailing list