[CMake] Why are blank-delimited strings in commands escaped on Linux?

Alan W. Irwin irwin at beluga.phys.uvic.ca
Fri Oct 2 11:45:46 EDT 2009


On 2009-10-02 14:45+0200 Hendrik Sattler wrote:

> Zitat von Claudio Bley <b_l_e_y at ml1.net>:
>>> But I think that his example is wrong, it should be:
>>> set(a "-Lfoo -lbar")
>>> message(STATUS "a = ${a}")
>>> set(a_list ${a})
>>> message(STATUS "a_list = ${a_list}")
>>> 
>>> Then the result should be
>>> -- a = -Lfoo -lbar
>>> -- a_list = -Lfoo;-lbar
>> 
>> No, should it not. How should that be possible? ${a} is not a list, it's
>> a string (ie. it does not contain semi colons).
>> 
>> The output is:
>> 
>> ,----
>> | -- a = -Lfoo -lbar
>> | -- a_list = -Lfoo -lbar
>> `----
>
> Then explain the detailed difference between the following three:
> set(a_list -Lfoo -lbar) -> creates a list with "-Lfoo" and "-lbar"
> set(a_list ${a}) -> ???
> set(a_list "${a}") -> ???

Hi Hendrik:

Just in case you haven't done this for yourself yet, here are the results from

set(a "-Lfoo -lbar")
message(STATUS "a = ${a}")
set(a_list ${a})
message(STATUS "a_list = ${a_list}")
set(a_quoted_list "${a}")
message(STATUS "a_quoted_list = ${a_quoted_list}")
set(a_real_list -Lfoo -lbar)
message(STATUS "a_real_list = ${a_real_list}")

-- a = -Lfoo -lbar
-- a_list = -Lfoo -lbar
-- a_quoted_list = -Lfoo -lbar
-- a_real_list = -Lfoo;-lbar

So it makes absolutely no difference _in this context_ whether you quote ${a}
or not.  The fourth example is just for completeness.  I hope most here know
already from similar experiments that real CMake lists are equivalent to
semicolon-delimited strings.

As for your request to explain why the second and third results are
identical, I leave that to those who understand how and why CMake has been
implemented in the way it has. I am not in that group, which is why I always
fall back to simple experiments like above to determine CMake behaviour.

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state implementation
for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
package (plplot.org); the libLASi project (unifont.org/lasi); the Loads of
Linux Links project (loll.sf.net); and the Linux Brochure Project
(lbproject.sf.net).
__________________________

Linux-powered Science
__________________________


More information about the CMake mailing list