[CMake] why no cumulative variable operations via the commandline?
René J. V. Bertin
rjvbertin at gmail.com
Sat Mar 19 13:03:23 EDT 2016
Nicholas Braden wrote:
> sense. Could you give an example of when you would find them useful? I
> think maybe I am not understanding what you want.
Yeah, I realise my explanation may not have been very clear.
> If you just want to pass a list of values to a variable on the command
> line, separate the values with semicolons:
> cmake "-DMY_LIST=example value 1;example value 2"
Now take an example where you are in fact assembling the commandline in
subsequent steps. A good example would be a build system like MacPorts that uses
a kind of header files (so-called PortGroups) that can be included by the build
scripts for packages of dependent software (say, the Kate5 editor). There's a
PortGroup for cmake itself, and there's a PortGroup for Qt5 and one for the KF5
frameworks. Each of those PortGroups can provide an element for MY_LIST (think
of the module path, or preprocessor tokens), but evidently they cannot make
assumptions about the contents of the variable.
In other words, it would make sense for certain types of programmatically
generated commandlines to do things like
cmake -DMY_LIST+=val1 -DMY_LIST+=val3 -DMY_LIST+=val2
At the moment we can do this reliably by using our own registers, one for each
CMake variable that might be used this way, splicing them into the commandline
just before invoking cmake. Not impossible, but somewhat of a hassle and a pity
for a feature that seems useful and probablye rather trivial to implement.
CMake commandline can get quite long, so this might even make sense as a
convenience for composing one manually.
Of course it would be convenient to have a concatenation operator in the cmake
language too ;)
R
More information about the CMake
mailing list