[CMake] out of source command line flag
Brad King
brad.king at kitware.com
Mon Sep 7 11:28:50 EDT 2009
Roman Shtylman wrote:
> Well...I didn't foresee such a discussion on the topic but have actually
> heard some interesting new things brought up...so I guess I can chime in too.
>
> 1. Being able to call cmake with
> $> cmake <build dir> <source dir>
> Although it is better than what we have now, I like the explicit
> nature of the -B <build dir> (or other flag) coming before the
> directory specification. It makes it very clear what is going to
> happen. It also doesn't tie you to a particular ordering of the
> command line arguments.
That's a good point. While it might be obvious to CMake which
directory is build and which is source, it might not to the human
reading the command line. I'll vote for the explicit switch.
> 2. I really like the idea of being able to specify a *default* out of
> source directory to prevent in source builds altogether. From a
> developer standpoint...if you could have that option be in the
> CMakeLists.txt file (maybe before PROJECT) then I think that would be
> the most obvious place for future maintainers to look.
A lot of things happen before CMakeLists.txt even starts running,
and files will have already been written to the build tree.
> If you start
> adding other files (i.e. InSource.cmake) you add more places where
> people need to look for configuration options.
Eric's point is good. The file could be used for other things too.
A *long* time ago we tried to create a PreLoad.cmake file for some
purpose I can't remember. We never got it working well, but it was
not quite the same thing we are discussing here.
An important clarification is that any kind of PreConfigure.cmake
file would be loaded without any build tree or cache. Anything it
does won't make it into the real CMakeLists.txt processing...no
variables or cache settings. The file would be an interface to
tell CMake about some project information or preferences. This
could include things like:
1.) Default build directory for attempted in-source builds
2.) Eric's option C...default cache entries. For the CMake
GUI they could appear before the first Configure starts.
3.) A mapping from "--prefix"-style options to cache entries.
The output of "cmake --help <src-tree|bld-tree>" could
include these options as project-specific help.
Idea #3 is a long-requested feature anyway.
-Brad
More information about the CMake
mailing list