[CMake] SET_SOURCE_FILES_PROPERTY and multiple args

Alexander Neundorf a.neundorf-work at gmx.net
Tue Jul 17 16:08:33 EDT 2007


On Tuesday 17 July 2007 15:51, James Bigler wrote:
> I have some code that sets a property and then I try to get it out later. 
> This property is some customized flags to the program:
>
> SET(MY_FLAGS_VAL "-Wall;-w512;-DSCI_NOPERSISTENT")

I think the qoutes here don't change a lot
SET(MY_FLAGS_VAL -Wall -w512 -DSCI_NOPERSISTENT)
would be the same. The semicolons already make it a list.

> SET_SOURCE_FILES_PROPERTIES(myfile.w PROPERTIES MY_FLAGS ${MY_FLAGS_VAL})
> GET_SOURCE_FILE_PROPERTY(myflags myfile.w MY_FLAGS)
> MESSAGE("myfile.w:MY_FLAGS = ${myflags}")
>
> The problem I'm having is that only the first flag ("-Wall") gets set.  The
> rest are ignored.
>
> When I specify the flags explicitly it works fine:
> SET_SOURCE_FILES_PROPERTIES(myfile.w PROPERTIES MY_FLAGS
> "-Wall;-w512;-DSCI_NOPERSISTENT")
>
> I tried this:
>
> SET(MY_FLAGS_VAL "-Wall -w512 -DSCI_NOPERSISTENT")
>
> But CMake replaced the spaces with '\ ' making the three args one arg.
>
> Is it possible to set a source file property with a variable's value?

SET_SOURCE_FILES_PROPERTIES(myfile.w PROPERTIES MY_FLAGS "${MY_FLAGS_VAL}")
should work.

Alex


More information about the CMake mailing list