[CMake] problem getting defines quoted properly

Andreas Pakulat apaku at gmx.de
Fri Jan 14 18:38:30 EST 2011


On 14.01.11 21:57:39, Michael Hertling wrote:
> On 01/14/2011 08:25 PM, 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 \?
> 
> No, you probably need a configured header. ;)

Not an option at this point as that would require source-code changes,
which I cannot justify right now.

> The documentation of ADD_DEFINITIONS() states
> 
> "Flags beginning in -D or /D that look like preprocessor definitions are
> automatically added to the COMPILE_DEFINITIONS property for the current
> directory."
> 
> and from the COMPILE_DEFINITIONS directory property's documentation:
> 
> "The VS6 IDE does not support definition values with spaces..."
>      ^^^

Sorry, I guess I should've added that I'm using NMake Makefiles, so the
above shouldn't apply. And at least cl.exe is capable of getting values
with spaces as the existing build-system does exactly that ;)

The problem is that in the generated file thats passed to cl (btw. is
there a way to let cmake not delete this file so I can look into it) the
qupting is incorrect and hence cl considered "BAZ" a source file instead
of part of a define.

Andreas

-- 
Tomorrow will be cancelled due to lack of interest.


More information about the CMake mailing list