[CMake] Quoted String

Brandon Van Every bvanevery at gmail.com
Tue Jul 31 11:40:17 EDT 2007


On 7/31/07, Alexander.Camek at elektrobit.com
<Alexander.Camek at elektrobit.com> wrote:
> Hi List,
>
> I want to add a definition to the compiler, so I do an ADD_DEFINITIONS().
> The defintion I want to add is a quoted string which should be parsed with leading and ending ".
> So I tried to escape it with \, but this doesn't also work.
>
> It should look like ADD_DEFINITIONS(-DPPATH="${path_to_somewhere}"), and then in the used c file the preprocessor will parse PPATH to "/path_to_somewhere".
> But it currently pares it wihtout the quote sign. In the c file it will be used as a char*, so the quotes are important.
>
> How can this be done?

It's a nightmare but it can be done.  Chicken does it.  You have to be
really really careful about all the different levels of escapes and
quotes.  Sometimes \" is all you need.  Sometimes \\\" is what you
need, because you need double \\ to survive CMake argument processing.
 It doesn't help that MACROs consume quotes when they shouldn't, as
per bug #5389.  The first thing you need to do is figure out the exact
point in your conversion(s) where you're losing the quotes.  \" does
work in SET assignments.

Chicken succeeds at this, so if you want to wade through the code to
figure out how to configure *.h files and so forth, it might be
helpful to you.
http://www.call-with-current-continuation.org

Cheers,
Brandon Van Every


More information about the CMake mailing list