[CMake] out of source command line flag
Eric Noulard
eric.noulard at gmail.com
Sat Sep 5 11:41:19 EDT 2009
Continued....
2) In the same way I did file a bug report for being able to enforce
out-of-source if necessary.
http://public.kitware.com/Bug/view.php?id=6672
2009/9/5 Bill Hoffman <bill.hoffman at kitware.com>:
>
> I use this all the time, and so do lots of people that I know. They do this:
Yes right I do that too.
However it may be easy to follow Roman initial idea and replace:
cmake -B ./debug -DDebug=1 .
cmake -DDebug=1 ./debug .
i.e keep current usage:
cmake [options] <path-to-source>
cmake [options] <path-to-existing-build>
and add:
cmake [options] <path-to-build> <path-to-source>
cmake [options] <path-to-source> <path-to-build>
if you call cmake with 2 paths arguments then
one argument should be the source tree
other argument should be the build tree.
Note however that in this case <path-to-build> may not exist at all.
CMake may guess which one is the build tree using this algorithm.
1) If there is a CMakeCache.txt in the dir then this is a build tree
2) If the path does not exists then this is a "to be created" build tree
error cases are:
E1) One gives two existing dir with none containing a CMakeCache.txt
==> send an error message explaining that and abort.
E2) One gives two directories
E21) both contains a CMakeCache.txt
or E22) one contains a CMakeCache.txt and the other does not exists.
E21 is plain wrong
E22 the source tree may have been polluted with a previous
in-source config.
E3) One gives a build tree which does not correspond to the given source tree
This is easy to check because CMakeCache.txt contains
<PROJECT>_SOURCE_DIR
If this appear CMake should abort and send a message telling
the source tree/build tree mismatch.
This does not look like that complicated and will keep full backward
compatibilty without adding extra "-B" option.
To be clear I'm not wanting to apply for providing a patch but may
be Roman would like to try ?
May be worth trying if other find the idea interesting.
--
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org
More information about the CMake
mailing list