[CMake] How to handle git branches

Andreas Pakulat apaku at gmx.de
Wed May 19 17:30:16 EDT 2010


On 19.05.10 09:11:24, Michael Hertling wrote:
> On 05/18/2010 09:18 PM, Andreas Pakulat wrote:
> > On 18.05.10 20:59:50, Michael Wild wrote:
> >> On 18. May, 2010, at 20:52 , Andreas Pakulat wrote:
> >>> I've recently bumped into a few problems with my usage of cmake on a
> >>> git-hosted project and am wondering what others are doing in such cases.
> >>>
> >>> The setup is as follows: The project's master branch has its dedicated
> >>> builddir. Now when working on a feature I create a branch from master,
> >>> but I re-use the buildsystem as maintaing n builddirs is a pita. 
> >>>
> >>> This however brings problems with it as far as I can see, specifically
> >>> when switching back to master branch (for example to merge somebody
> >>> else's feature-branch and push it later on) as git resets the
> >>> modification times of files according to the branch. For make-based
> >>> systems that rely on those modification times this if of course
> >>> horrible, hence I ended up with various bogus build problems, ranging
> >>> from generated-source-files not being re-generated, strange compiler
> >>> errors to even linking errors because .o files weren't re-created.
> >>>
> >>> So I'm wether anybody here has a good recipe how to handle this with the
> >>> cmake-generated makefiles? I'd like to avoid having separate builddirs
> >>> for each branch and just as well to do a full make clean each time the
> >>> branch is being changed (as that would mean exploding compile times).
> >>
> >> I never had the problem of bogus builds, only that Make decided to
> >> re-compile a lot of stuff that didn't need to be rebuilt.
> > 
> > Well, I didn't further investigate, but I do know that the
> > modification-time of one of the files is older in my master branch than
> > in the feature branch. Hence upon checking out master the modification
> > time was "older" than the one of the .o file (a lot older) and hence
> > make didn't rebuild it. At the same time there is a binary
> > incompatibility between the two branches.
> 
> AFAIK, when switching branches, Git sets the timestamps of all files
> which get modified due to the branch switching to the current time, so
> you should never end up with modified files being "aged". Possibly, in
> particular when switching back immediately, this results in unmodifed
> files with new timestamps which are subsequently recompiled without
> need, as MW has already mentioned. For instance, see:

Hmm, I can see that happening here right now, so no idea how I got into
the state where one of the files had an older timestamp or how I got
into all those compile-problems. I'll keep an eye out on this.

Andreas

-- 
Tomorrow, this will be part of the unchangeable past but fortunately,
it can still be changed today.


More information about the CMake mailing list