[CMake] add_definitions & "string" values

Alexander Neundorf a.neundorf-work at gmx.net
Tue Jun 12 13:13:24 EDT 2007


On Tuesday 12 June 2007 12:38, Welter Luigi Silva wrote:
> Hi again,
> I'm trying to have a definition with a string value, say, "foo".
> However, when I tried the following command:
>
> add_definitions(-DFOO="foo")
>
> and used FOO in my source file -- in a command like printf("%s\n", FOO) --
> I got 'foo' without the quotes, which is not a valid string literal, as
> I wished it was.
> I've also tried the command bellow but it did not work as well:
> add_definitions(-DFOO="\"foo\"")

You need more escaping, the following should work:
add_definitions(-DFOO=\\"foo\\")

Alex


More information about the CMake mailing list