[cmake-developers] ExternalProject CMAKE_ARGS and CMAKE_CACHE_ARGS arguments

Daniele E. Domenichelli daniele.domenichelli at gmail.com
Tue Oct 21 10:01:19 EDT 2014


On 20/10/14 15:52, Brad King wrote:
> On 10/16/2014 11:26 AM, Daniele E. Domenichelli wrote:
>>   #    [CMAKE_ARGS args...]        # Arguments to CMake command line
>>   #    [CMAKE_CACHE_ARGS args...]  # Initial cache arguments, of the form -Dvar:string=on
>>
>> So, from what I understand, The first arguments are passed to the cmake
>> command line, and from the second it is created a a cache file that is
>> passed to cmake using -C. If the same variable is in both, CMAKE_ARGS
>> wins over CMAKE_CACHE_ARGS.
> [snip]
>> This makes impossible to change a value later, and in my opinion makes
>> one of the 2 arguments redundant, since the final effect of the 2
>> variables is exactly the same.
> 
> CMAKE_CACHE_ARGS was added here:
> 
>  Added CMAKE_CACHE_ARGS to ExternalProject.
>  http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=68cd3fe0
> 
> to overcome command line length limits.  CMAKE_ARGS can contain
> arguments other than cache values.  Therefore they are not fully
> redundant although there is overlap.

Ok, I see.

I would like to be able to set some some variables (for example
CMAKE_BUILD_TYPE) for all the "external project" according to the value
in the "super-project", but the same time I would like to be able to
change them (for example change CMAKE_BUILD_TYPE to Debug if I'm
building in Release mode) for just one external project without changing
it in all of them, and having to rebuild everything.
But actually I don't like the idea that all of them could be modified,
for example in my case the user should not have the control over the
CMAKE_INSTALL_PREFIX variable...

Maybe, since the "-D" is actually a convention to match the CMAKE_ARGS
argument that does some sort of conversion from "-Dvar:type=value" to a
"set(var value CACHE type "Initial cache" FORCE)" command, it could be
possible to accept some other form of string, maybe "+D", or "-<some
other uppercase letter>", so that:

 -Dvar:type=value -> set(var value CACHE type "Initial cache" FORCE)
 +Dvar:type=value -> set(var value CACHE type "Initial cache" )

This would ensure backwards compatibility, with no extra arguments and
could allow a quick switch from forced to non-forced, just by changing
one character.

Would you accept something like this?


Cheers,
 Daniele




More information about the cmake-developers mailing list