[CMake] add_definitions & "string" values

Bill Hoffman bill.hoffman at kitware.com
Tue Jun 12 14:25:28 EDT 2007


Filip Brcic wrote:
>
> Yes, and for increased readability, I would suggest you to use:
>
> add_definitions(-DFOO="\\"foo\\"")
>
> so that you get
>
> gcc -DFOO="\"foo\"" yourfile.c
>
> when CMake compiles your file and, obviously, FOO="foo" in C.
>
> On the sidenote, how does that relate to various shells? I'm using bash, but 
> did anybody cases with escapes like this one in other shells such as csh, 
> zsh, {,d}ash, or Micro$oft's favourite - ksh?
>   
Of course a better way to do that IMO, is to configure a file.

#cmakedefine FOO "@somevalue@"

That way there are no shell issues.

-bill



More information about the CMake mailing list