[CMake] problem getting defines quoted properly

Andreas Pakulat apaku at gmx.de
Mon Jan 17 06:38:09 EST 2011


On 14.01.11 20:25:25, Andreas Pakulat wrote:
> Hi,
> 
> I'm trying to set a define so that it can be used as string-literal in
> C++ code using add_definitions. This:
> 
> add_definition( -DMYFOO=\"BAR BAZ\" )
> 
> works fine on linux, but breaks with MSVC6 on windows. I always thought
> I understood cmake's quoting rules, but apparently I'm wrong :(
> 
> I've already tried:
> add_definition( -DMYFOO=\\\"BAR BAZ\\\" )
> 
> What I didn't think of trying when I was at the machine is
> add_definition( -DMYFOO=\\"BAR BAZ\\" )
> 
> Would that be the correct one? Or do I need even more \?

It just turned out that the problem was not the above, in particular since
I require version 2.8 which sets CMP0005 to NEW. Hence cmake takes care of
proper quoting itself.

The problem was rather an earlier add_definitions line which tried to set a
define that included a semicolon. Apparently that is something that make
cmake create completely bogus CXX_DEFINES lines in the flags.make file.
I've reported a bug about that now.

Andreas

-- 
Chess tonight.


More information about the CMake mailing list