[CMake] Escaping $

Brad King brad.king at kitware.com
Fri Sep 22 08:50:31 EDT 2006


Kedzierski, Artur CIV NAVSURFWARCENDIV CORONA wrote:
> 	Hi,
> 
> 	I am trying to create FooConfig.cmake by having
> FooConfig.cmake.in and running CONFIGURE_FILE(FooConfig.cmake.in
> FooConfig.cmake)
> on it.
> 	In FooConfig.cmake.in, I have something like:
> SET(MY_LOCAL ${CMAKE_INSTALL_PREFIX}/include/foo)
> IF (WIN32)
> 	SET(MY_LOCAL \$(MY_LOCAL) ${CMAKE_INSTALL_PREFIX}/include/foo_win32)
> ENDIF (WIN32)
> SET(Foo_INCLUDE_DIR \$(MY_LOCAL)
> 
> 	My goal is to have this generated:
> SET(MY_LOCAL /usr/include/foo)
> IF (WIN32)
> 	SET(MY_LOCAL $(MY_LOCAL) /usr/include/foo_win32)
> ENDIF (WIN32)
> SET(Foo_INCLUDE_DIR $(MY_LOCAL)
> 
> 	In other words, I want to escape dollar sign for $(MY_LOCAL) so
> that it doesn't get evaluated during creation of FooConfig.cmake. How
> do I do that? "\$" leaves it as it is and $$ doesn't work either. 
> 	Is there any other way of escape the dollar sign?

Pass the @ONLY argument to CONFIGURE_FILE and then you don't need to
escape ${} syntax at all.  Note that you should be using $ with curly
braces, not parens.  For variables you do want replaced in the
configured file refer to them as @MYVAR at .

-Brad


More information about the CMake mailing list