[CMake] out of source command line flag

Hendrik Sattler post at hendrik-sattler.de
Sat Sep 5 03:38:47 EDT 2009


Am Freitag 04 September 2009 21:58:02 schrieb Alexander Neundorf:
> On Sunday 09 August 2009, Roman Shtylman wrote:
> > I have been meaning to try and create such a patch for a while. The
> > idea behind the patch is that you can specify the location of the out
> > of source build directory on the command line. By itself, this really
> > isn't all that useful save having to type mkdir 'some dir', cd 'some
> > dir', and 'cmake ..'
> >
> > I think the use in this feature comes from being able to do something
> > like the following from WITHIN the source tree
> >
> > $> cmake -B ./debug -DDebug=1 .
> > $> cmake -B ./release -DRelease=1 .
> >
> > This will create directories 'debug' and 'release' in the source tree
> > where it will put all of the cmake cache files and whatnot from the
> > build. Each directory will then be using the appropriate things
> > triggered by having set the -D ... note... this is just a simple
> > example
> >
> > I used the -B flag (as it was already there and I couldn't tell what
> > else it was currently doing) ... but pardon me if it actually had a
> > previous purpose.
> >
> > This patch is not meat to be exhaustive (as I might have missed a
> > usage scenario with cache files or whatnot), but it does demonstrate
> > the capability I am looking for.
> >
> > Feedback is welcome...or if you think this feature is utterly
> > worthless let me know :) I wanna hear why it can't work (don't just
> > say...well, you could have just made the directory and done all that
> > within it...yea...I know...but the point is that I didn't have to :) )
> 
> Hmm, from my POV this patch doesn't add functionality to cmake, and it adds
>  a second way to do one thing. Personally I wouldn't vote for including the
>  patch.
> Don't know what the others say.
> Documentation is missing.

The problem with how giving the build-dir/source-dir to cmake is currently too 
much dependent on other conditions:
  cmake [options] <path-to-source>
  cmake [options] <path-to-existing-build>

The first only is true if no CMakeCache.txt exists there. This was actually a 
bad choice to have that as only possibility.
Being able to do an out-of-source build even if there was a previous in-source 
build would be much appreciated.

HS



More information about the CMake mailing list