[CMake] Status of escaped characters in cmake?

David Cole david.cole at kitware.com
Tue Jul 19 22:26:39 EDT 2005


This works for me on CMake 2.0.5 on Windows... Setting a plain $ into a 
variable is not a problem and doesn't need escaping unless it's followed 
by an opening curly brace '{'. Even then escaping doesn't seem to be the 
solution - that tricky bit has to be done in two stages (as far as I can 
tell...) :-)

Like so:
MESSAGE(SEND_ERROR "Setting DOLLAR_LITERAL to $")

SET(DOLLAR_LITERAL "$")
MESSAGE(SEND_ERROR "Stage1-DOLLAR_LITERAL='${DOLLAR_LITERAL}'")

SET(DOLLAR_LITERAL "${DOLLAR_LITERAL}{DOLLAR_LITERAL}")
MESSAGE(SEND_ERROR "Stage2-DOLLAR_LITERAL='${DOLLAR_LITERAL}'")

SET(TWO_CENTS "It cost $0.02 for this advice...")
MESSAGE(SEND_ERROR "TWO_CENTS='${TWO_CENTS}'")

There's some way to jam ascii character values by number into variables, 
too, but I can't remember where I saw that right now.

HTH,
David


Chris Green wrote:

> Hi,
>
> How do I get a literal $ into a CMAKE variable or message? I've done 
> some searching of archives but not seen anything. I'm using 2.0.6 on 
> CYGWIN and 2.2.0 on Linux.
>
> Any help appreciated.
>
> Thanks,
> Chris.
>


More information about the CMake mailing list