[CMake] Proper way to define a list

Robert Dailey rcdailey at gmail.com
Mon Mar 30 16:30:23 EDT 2009


I thought there was no explicit string syntax in CMake. After all, you can
do this:
message( Hello )

using no quotes.

Suppose I have a list of files:

C:\file 1.txt
C:\file 2.txt

Notice the space in each one.

If I wanted to create a list of these files. I would naturally do:

set( filelist C:\file 1.txt;C:\file 2.txt )

See the confusion? There's spaces (with unintended meaning to set() ) mixed
with semi-colons. What would one do in this example?

On Mon, Mar 30, 2009 at 3:09 PM, BRM <bm_witness at yahoo.com> wrote:

> That's correct - it is 1 parameter versus 3, but for a different reason.
>
> DoStuff( a b c )
>
> Processes each as 3 different variables to be passed, each of type and
> value a, b, and c respectively.
>
> DoStuff( "a b c" )
>
> Processes it as 1 variable - a string containing the value "a b c".
>
> If you have the string
>
> DoStuff( "a;b;c" )
>
> Then that variable will be of the value "a;b;c" with literal semi-colons in
> it. I believe that was Bill's point.
>
> Ben
>
> ------------------------------
> *From:* Robert Dailey <rcdailey at gmail.com>
> *To:* Bill Hoffman <bill.hoffman at kitware.com>
> *Cc:* cmake at cmake.org; a.neundorf-work at gmx.net
> *Sent:* Monday, March 30, 2009 3:47:15 PM
> *Subject:* Re: [CMake] Proper way to define a list
>
> On Mon, Mar 30, 2009 at 2:41 PM, Bill Hoffman <bill.hoffman at kitware.com>wrote:
>
>> Alexander Neundorf wrote:
>>
>>> On Monday 30 March 2009, Robert Dailey wrote:
>>>
>>>> Hi,
>>>> What's the proper way to define a list? Suppose I have 3 words: Foo,
>>>> Bar,
>>>> and Baz. I want these 3 strings to be in a list called Stuff. Would I do
>>>> this:
>>>>
>>>> set( Stuff "Foo;Bar;Baz" )
>>>>
>>>> Is this correct?
>>>>
>>>
>>> Yes, this is identical to
>>> set( Stuff Foo;Bar;Baz )
>>> and also to set( Stuff  Foo Bar Baz )
>>>
>>>
>> Actually set(var "a;b;c") with the double quotes will create a string with
>> literal ;'s in it...
>
>
> I thought quotes were used to force whatever is inside of it to be treated
> as a single parameter. So for example, if I had a function called DoStuff,
> you could call it 2 ways:
>
> DoStuff( a b c )
> DoStuff( "a b c" )
>
> My understanding is that the first one will send 3 parameters to DoStuff.
> The second will send only 1 parameter that is a list of 3 items.
>
> Also, what if I do this:
>
> set( Stuff foo bar;baz )
>
> What will happen here?
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090330/96ea97f1/attachment.htm>


More information about the CMake mailing list