[CMake] out of source command line flag

Roman Shtylman shtylman at gmail.com
Mon Sep 7 11:59:53 EDT 2009


> 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:

I like this idea as it provides a good place to put any *init* related
config. Providing a default build directory seems very reasonable to
me and I think that many project would actually benefit from such a
feature. IMHO in-source builds interfere too much with the source tree
(obviously) and out of source builds (and all the intermediate files)
are much easier to ignore with version control systems.

On top of the PreConfigure.cmake file I still think the -B <build dir>
flag might have be of benefit... unless the PreConfigure.cmake allows
you to setup more than one build directory and the options that will
be defined in it? That would be rather useful as you could setup debug
and release directories and specify the default directory all from one
file. Maybe this starts becoming more of a project preferences or
setup file...

~Roman

On Mon, Sep 7, 2009 at 11:28 AM, Brad King<brad.king at kitware.com> wrote:
> 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.
>

>
> 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