[CMake] Passing parameters via command prompt

Steven Van Ingelgem steven at vaningelgem.be
Wed Nov 26 11:50:00 EST 2008


What I would like to do is create some kind of batch generation for every
combination of debug/release, static/dynamic.

So I would call:
echo building static release
cmake -D cfg=release -D link=static .
make all && make install

echo building dynamic release
cmake -D cfg=release -D link=dynamic .
make all && make install


etc ...

However when I call the set() it overwrites the cached value.
It should only be called if I didn't get a parameter from the commandline.

So for example the first time I call "cmake -D cfg=release -D link=static
.".
cfg and link is set.
But if I call "cmake -D cfg=debug ." afterwards,
cfg is set to debug, and link is set to static (as being the previous cached
entry).

Do you think it would be ok for the end-user?


If so, than I could simply do a "if(not cfg) set(cfg <default> cache)" as to
set the default cfg entry.


grtz,
Steven




2008/11/26 David Cole <david.cole at kitware.com>

> There is not a good/easy way to do this that I can think of off the top of
> my head...
> Why do you need to tell where a variable came from...?
> What are you going to do differently based on this information?
>
>
> On Wed, Nov 26, 2008 at 10:03 AM, Steven Van Ingelgem <
> steven at vaningelgem.be> wrote:
>
>> Hi,
>>
>>
>> How can I determine which parameters have been entered via command line,
>> which come from the script and which from the cache?
>>
>> For example:
>> --------
>> MESSAGE(STATUS "TEST (before): ${TEST}")
>> SET(TEST "a")
>> MESSAGE(STATUS "TEST (after): ${TEST}")
>> --------
>>
>> C:\tmp>cmake . -G"MinGW Makefiles"
>> -- TEST (before):
>> -- TEST (after): a
>> C:\tmp>cmake .
>> -- TEST (before):
>> -- TEST (after): a
>> C:\tmp>cmake -D TEST=b .
>> -- TEST (before): b
>> -- TEST (after): a
>> C:\tmp>cmake .
>> -- TEST (before): b
>> -- TEST (after): a
>>
>> What I want to detect is how the parameter is set. Via the cache (4th
>> step), via the command line (3rd step) or via the script (step 1/2)?
>>
>> Can anyone help me with that?
>>
>>
>> Thanks,
>> Steven
>>
>>
>>
>> _______________________________________________
>> CMake mailing list
>> CMake at cmake.org
>> http://www.cmake.org/mailman/listinfo/cmake
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20081126/060c11ec/attachment-0001.htm>


More information about the CMake mailing list