[CMake] How to not evaluate variable names ?

David Cole david.cole at kitware.com
Wed Sep 30 07:40:12 EDT 2009


Are you using "FILE(WRITE"...?
What version of CMake?

This should work. Send the CMake code snippet you are using to try to do
this so that we can see what might be wrong.

If using older CMake (2.4.something) then you may have to do:
  set(DOLLAR "$")
  file(WRITE blah "${DOLLAR}{varNameHere}")

...but escaping the "$" inside a string literal has worked for quite some
time now... I'd like to know if you have a different use case or are just
seeing older-versioned CMake behavior.



On Wed, Sep 30, 2009 at 3:54 AM, <fred.antares at free.fr> wrote:

> Quoting Marcel Loose <loose at astron.nl>:
>
> > On Wed, 2009-09-30 at 09:28 +0200, fred.antares at free.fr wrote:
> > > Quoting Jeroen Dierckx <jeroen.dierckx at gmail.com>:
> > >
> > > > On Wed, Sep 30, 2009 at 8:32 AM, <fred.antares at free.fr> wrote:
> > > >
> > > > > Hi,
> > > > >
> > > > > I've seen a previous discussion on this subject, but unfortunately,
> > none of
> > > > > the
> > > > > given solutions (as described on
> > > > > http://www.cmake.org/Wiki/CMake:VariablesListsStrings) seem to
> work in
> > my
> > > > > case.
> > > > >
> > > > > I'm using CMake to generate an XML config file, and one of the tags
> > must
> > > > > have an
> > > > > argument as follows: args="${serverConfigChanged}". The XML is used
> by
> > > > > CruiseControl, and unfortunately, it uses the same variable syntax
> as
> > > > > CMake. I
> > > > > tried almost every combination of escaping, double dollars, but
> > couldn't
> > > > > get the
> > > > > correct output.
> > > > >
> > > > > Is there some way to achieve that directly from the CMakeList.txt,
> or
> > > > > should I
> > > > > do that in the generator code ?
> > > > >
> >
> > Hi Jeroen,
> >
> > What about:
> >
> > file(WRITE /tmp/dummy.xml "args=\"\${serverConfigChanged}\"\n")
> >
> > That works for me. You must escape the double quotes (") and the dollar
> > sign ($).
> >
> > Best regards,
> > Marcel Loose.
> >
> >
>
> Unfortunately, it doesn't work. I already tried escaping the dollar sign
> and the
> result in that case is args="".
>
> Fred
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090930/c89244bf/attachment.htm>


More information about the CMake mailing list