[CMake] Building a Version Header

Marcel Loose loose at astron.nl
Fri Jul 9 04:27:13 EDT 2010


Hi Daniel, Clark,

I've got a solution that rebuilds a .h and .cc file whenever anything
has changed in your working copy, e.g. an 'svn update'. It also records
local modifications that have not been checked in yet.

However, if you plan to include this version header file in *every*
source you're compiling, I would discourage using my solution, because
it will trigger too many complete rebuilds.

Anyway, if you're interested, let me know. The code is GPL.

Best regards,
Marcel Loose.

Op donderdag 08-07-2010 om 16:01 uur [tijdzone -0500], schreef Daniel
Blezek:
> Sounds good.  Incidentally, we did something similar with Subversion, but I
> never got it to work 100% of the time.  Glad it works well for you!
> 
> Cheers,
> -dan
> 
> 
> On 7/8/10 3:54 PM, "Clark Gaebel" <cg.wowus.cg at gmail.com> wrote:
> 
> > I don't want it run every commit, I want it run every build.
> > 
> > Right now, it seems to be re-updating every time I run "make", so it's
> > all good.
> > 
> > Thanks for your suggestion anyways!
> > 
> > On 07/08/10 16:34, Daniel Blezek wrote:
> >> One alternative is to use git itself.  There is a "git smudge" option that
> >> can do much of what you are asking.  However, I've never done this sort of
> >> thing.
> >> 
> >> http://progit.org/book/ch7-2.html
> >> 
> >> Just $0.02,
> >> -dan
> >> 
> >> 
> >> On 7/8/10 3:31 PM, "Tyler Roscoe" <tyler at cryptio.net> wrote:
> >> 
> >>   
> >>> On Wed, Jul 07, 2010 at 10:43:15PM -0400, John Drescher wrote:
> >>>     
> >>>> On Wed, Jul 7, 2010 at 9:44 PM, Clark Gaebel <cg.wowus.cg at gmail.com> wrote:
> >>>>       
> >>>>> I would like to generate file that looks something like this:
> >>>>> 
> >>>>>    // version.h
> >>>>>    #define VERSION "v0.1-345-ga77ede8"
> >>>>>         
> >>>> You want to do that with configure_file
> >>>>       
> >>> The upside of this approach is that it's simple. The downside is that it
> >>> is only run (and thus your version header is only updated) whenever
> >>> CMake runs. It's possible for the source code to change without
> >>> triggering a re-run of CMake.
> >>> 
> >>> Consequently, we use a custom command to call a python script at build
> >>> time. The script writes out the header with the up-to-date version info.
> >>> 
> >>> tyler
> >>> _______________________________________________
> >>> 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
> >>>     
> >>   
> 




More information about the CMake mailing list