[CMake] Invoking CMakle outside of the build/source dir.

Bill Hoffman bill.hoffman at kitware.com
Mon Jun 6 11:44:35 EDT 2011


On 6/6/2011 11:33 AM, Yuri Timenkov wrote:
> I guess there are cases when you can't do this.
> For example, on Windows you can't simply call "cd -" or you may have
> other kind of script than sh one (for example ant).
>
> Also both source dir and binary dir may be relative to current
> directory, therefore you don't know neither absolute nor relative to
> bindir source path. And determining it may be quite cumbersome (again,
> in ant this can be done using property and property names are global and
> they're evaluated only once per script, so you can't easily wrap cmake
> call into macro).

There is sort of a backdoor...

You can use -H and -B on the command line like this:
cmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)

This is what cmake does inside makefiles.  It has been this way but 
un-documented for some time.  I suppose we could just document it.  I 
don't see a reason to stop support for it some day...

-Bill


More information about the CMake mailing list