[CMake] Where to put generated files.
Matthew Woehlke
matthew.woehlke at kitware.com
Wed Jun 12 15:49:02 EDT 2013
On 2013-06-12 15:30, William McKenzie wrote:
> Just wondering what the common convention is here. If I have some generated
> c/c++ source files, say from gSoap or Lex/Yacc (and my build rules take
> care of the generation), is the convention to generate these into the build
> folder, or the original source folder? I understand I could use either, and
> in some ways it makes more sense for them to go into the build folder. But
> it also feels a little weird that all of my c files are not in the same
> place if I do that.
Build directory. Configuring and building should never, ever alter the
source directory in any way. (It should be possible, even, to configure
and build successfully if the source directory is mounted read-only.)
Basically, generated artifacts of any kind should be kept separate from
non-generated, for several reasons:
- Makes version control much easier.
- Can get back to 'pristine' state simply by removing the build directory.
- Can have multiple builds with different configurations (or even
compilers) sharing a single source directory.
- Can ensure integrity of the source tree by making it immutable (see
above ;-)... not that I tend to do this, but it's still good to have the
ability if needed).
--
Matthew
More information about the CMake
mailing list