[CMake] seperate source/build directories (Was: cleaning targets)

Eric NOULARD eric.noulard at gmail.com
Thu Nov 6 17:05:15 EST 2008


Le Thu, 06 Nov 2008 14:15:21 -0700,
"Eric (Brad) Lemings" <brad at rebit.com> a écrit :

> Eric Noulard wrote:
> > 2008/11/6 Michael Jackson <mike.jackson at bluequartz.net>:
> >   
> >> All this is asking is 2 extra commands.
> >>     
> >
> > You may perfectly do that with autotools too:
> >
> > mkdir build
> > cd build
> > /path/to/source/configure
> > make
> > make install
> Right.  And because with autotools, the build process works as well in
> the source tree, in a build subdirectory, or completely separate build
> directory, no particular approach is preferred over another.
> 
> If CMake recommends one approach (or avoiding another), this implies
> it doesn't work well (or as well) with that approach because of
> shortcomings in the tool 

Nope, that's because some _usage_ of CMake _may_ break in-source build.
This mainly due to the fact that with CMake you have access
to 
CMAKE_BINARY_DIR
CMAKE_SOURCE_DIR
whereas with autotools you don't (unless I'm wrong).

However you may ALWAYS support both in-source and out-of-source 
with no limitation [known-to-me] with CMake.
However it's so much easier to 
rm -rf buildTree
than crafting
some "distclean" target with the help of the user which must specify
which files have been generated using it's "CUSTOM_COMMAND"

> rather than "it's good development practice". Or maybe its both?

That's because CMake is stricter than autotools for "generated" files.
CMake will ALWAYS generate files in the build tree
(unless you CONFIGURE_FILE to ${CMAKE_SOURCE_DIR}/.. or tell
 your CUSTOM_COMMAND to used source tree workdir or whatever)

Autotools generates a bunch of files in the source tree, beginning with
the "configured" files or Makefile.in coming from Makefile.am

None of autotools or CMake consider this as a "shortcoming" 
but rather a way to consider build life :=)

My personnal viewpoint on in-source build 
(either with autotools or cmake) is that's a pain for project using
version controlled source tree because you need something in order
to make cvs, svn, git or whatever ignore those extra non-versioned
files.

That's why I want to be able to enforce out-of-source build.
CMake is currently lacking this feature:
http://public.kitware.com/Bug/view.php?id=6672

Autotools won't currently add such feature because it already 
generates some files in the source tree whatever you do.


-- 
Erk


More information about the CMake mailing list