[CMake] Proper way to define a list

Alexander Neundorf a.neundorf-work at gmx.net
Mon Mar 30 16:38:56 EDT 2009


On Monday 30 March 2009, Robert Dailey wrote:
> 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?

set( filelist "C:/file 1.txt" "C:/file 2.txt" )
or
set( filelist "C:/file 1.txt;C:/file 2.txt" )

(a string with semicolons is basically a list, internally all cmake variables 
are just strings, lists are strings with semicolons)

Alex


More information about the CMake mailing list