[CMake] Fwd: ARGV to pass to CMAKE_COMMAND

Bill O'Hara billtohara at gmail.com
Tue Apr 7 18:11:53 EDT 2009


Perhaps I'm missing something. What I'm trying to do is script things so the
usercan do this

cd build
cmake -Dfoo=bar /path/to/sources
make

where the CMakeLists.txt in /path/to/sources actually ends up building
several different things by creating directories for each thing, stepping in
and calling cmake/make to build each piece. The trick will be to push
-Dfoo=bar into the sub-builds.

If I understand you correctly, I do the first cmake call with -Dfoo=bar,
pointing at my top-level CMakeLists.txt, and then call cmake again from the
same directory and picked up cached values? This is fine to repickup cached
-D values but will only work for the same sources, right? What I think I
want to do is

cd build
cmake -Dfoo=bar /sources
.... under the scenes we
.... mkdir a; cd a
.... cmake -Dfoo=bar /sources/a; make; cd ..
.... mkdir b; cd b
.... cmake -Dfoo-bar /sources/b; make; cd ..
make

I guess I could try grabbing some things from the top-level cache, but as
you mention, that seems open to later problems.

Am I misunderstanding your suggestion?

Thanks,
b.


On Tue, Apr 7, 2009 at 1:14 PM, Bill Hoffman <bill.hoffman at kitware.com>wrote:

> Bill O'Hara wrote:
>
>> Also to mail list.
>>
>> ---------- Forwarded message ----------
>> From: *Bill O'Hara* <billtohara at gmail.com <mailto:billtohara at gmail.com>>
>> Date: Tue, Apr 7, 2009 at 12:51 PM
>> Subject: Re: [CMake] ARGV to pass to CMAKE_COMMAND
>> To: a.neundorf-work at gmx.net <mailto:a.neundorf-work at gmx.net>
>>
>>
>> I think it makes sense for us. We have a quite large build and sometimes
>> users want to rebuild part of our software automatically rather than use a
>> preinstalled version. We can support this with recursive calls to cmake for
>> the particular code they are trying to build but we need to also pass down
>> whatever parameters they passed to the top-level cmake invocation. We don't
>> know them all ahead of time, nor do we really want to hardcode them
>> explicitly in the calls to cmake.
>>
>>
> I suppose you might be able to copy the CMakeCache.txt or parts of it down
> to the sub-project.  Any -D options given to cmake will be in the cache with
> lots of other stuff....  Also, it is not really a reliable thing to do
> anyway.   What if the user does this:
>
> cd build
> cmake -Dfooba=bar ../source
> cmake ../source   # this one does not have -Dfooba=bar on the command line,
> but it will have fooba set in the cache from the previous run.
>
> -Bill
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090407/aff3ac05/attachment-0001.htm>


More information about the CMake mailing list