so if you have this:<div> macro(blah arg1)</div><div> message("==${arg1}==")</div><div> endmacro(blah)</div><div><br></div><div> blah("${do_not_evaluate}")</div><div><div> blah("\${do_not_evaluate}")</div>
<div><div> blah("\\\${do_not_evaluate}")</div><div><br></div></div></div><div>you should see:</div><div>====<br></div><div><div>====<br></div><div><div>==${do_not_evaluate}==</div><div><br></div><div>I'm using CMake 2.6.4 to get these results. I think 2.4.8 should give you the same...</div>
<div><br></div></div></div><div>Because you are calling through a macro and there are multiple (in this case 2) levels of de-referencing happening, you need extra escaping to get the desired effect.</div><div><br></div><div>
I think you should be ok "as-is" with your code if you have the right number of escapes in there. Stuff like this is sensitive, though, and there might be a better way to approach it rather than adding escape characters till it works... (Re-design with the intent of passing ${xyz} string literals through the system without multiple levels of escaping...)</div>
<div><br></div><div>If you could post some code (or simplify it) others may be able to offer some more helpful suggestions.</div><div><br></div><div><br></div><div>HTH,</div><div>David</div><div><br></div><div><br></div><div>
<div class="gmail_quote">On Wed, Sep 30, 2009 at 8:09 AM, <span dir="ltr"><<a href="mailto:fred.antares@free.fr">fred.antares@free.fr</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
The problem is I'm working on quite a big project, and it was not written<br>
initially by me. I don't know about the "FILE(WRITE", but here's what I'm doing:<br>
- In the CMakelists, I'm calling a macro with one of the parameters being what I<br>
want in my attribute (in that case "${do_not_evaluate}").<br>
- This macro adds the attribute to a specific source group<br>
- The source group is parsed and interpreted by custom code that was added to<br>
CMake for our own generation needs<br>
- The arg ends up being added to a Tiny XML element<br>
- The XML file write is done from the custom code, by calling Write on the Tiny<br>
XML hierarchy<br>
<br>
The CMake version is 2.4.8, but customized with our own generators.<br>
<br>
Maybe the simpler thing, given the case and the lack of a direct solution, would<br>
be to add a specific string to the attribute, signaling to the code that it<br>
should be replaced ?<br>
<br>
Fred<br>
<div><div></div><div class="h5"><br>
Quoting David Cole <<a href="mailto:david.cole@kitware.com">david.cole@kitware.com</a>>:<br>
<br>
> Are you using "FILE(WRITE"...?<br>
> What version of CMake?<br>
><br>
> This should work. Send the CMake code snippet you are using to try to do<br>
> this so that we can see what might be wrong.<br>
><br>
> If using older CMake (2.4.something) then you may have to do:<br>
> set(DOLLAR "$")<br>
> file(WRITE blah "${DOLLAR}{varNameHere}")<br>
><br>
> ...but escaping the "$" inside a string literal has worked for quite some<br>
> time now... I'd like to know if you have a different use case or are just<br>
> seeing older-versioned CMake behavior.<br>
><br>
><br>
><br>
> On Wed, Sep 30, 2009 at 3:54 AM, <<a href="mailto:fred.antares@free.fr">fred.antares@free.fr</a>> wrote:<br>
><br>
> > Quoting Marcel Loose <<a href="mailto:loose@astron.nl">loose@astron.nl</a>>:<br>
> ><br>
> > > On Wed, 2009-09-30 at 09:28 +0200, <a href="mailto:fred.antares@free.fr">fred.antares@free.fr</a> wrote:<br>
> > > > Quoting Jeroen Dierckx <<a href="mailto:jeroen.dierckx@gmail.com">jeroen.dierckx@gmail.com</a>>:<br>
> > > ><br>
> > > > > On Wed, Sep 30, 2009 at 8:32 AM, <<a href="mailto:fred.antares@free.fr">fred.antares@free.fr</a>> wrote:<br>
> > > > ><br>
> > > > > > Hi,<br>
> > > > > ><br>
> > > > > > I've seen a previous discussion on this subject, but unfortunately,<br>
> > > none of<br>
> > > > > > the<br>
> > > > > > given solutions (as described on<br>
> > > > > > <a href="http://www.cmake.org/Wiki/CMake:VariablesListsStrings" target="_blank">http://www.cmake.org/Wiki/CMake:VariablesListsStrings</a>) seem to<br>
> > work in<br>
> > > my<br>
> > > > > > case.<br>
> > > > > ><br>
> > > > > > I'm using CMake to generate an XML config file, and one of the tags<br>
> > > must<br>
> > > > > > have an<br>
> > > > > > argument as follows: args="${serverConfigChanged}". The XML is used<br>
> > by<br>
> > > > > > CruiseControl, and unfortunately, it uses the same variable syntax<br>
> > as<br>
> > > > > > CMake. I<br>
> > > > > > tried almost every combination of escaping, double dollars, but<br>
> > > couldn't<br>
> > > > > > get the<br>
> > > > > > correct output.<br>
> > > > > ><br>
> > > > > > Is there some way to achieve that directly from the CMakeList.txt,<br>
> > or<br>
> > > > > > should I<br>
> > > > > > do that in the generator code ?<br>
> > > > > ><br>
> > ><br>
> > > Hi Jeroen,<br>
> > ><br>
> > > What about:<br>
> > ><br>
> > > file(WRITE /tmp/dummy.xml "args=\"\${serverConfigChanged}\"\n")<br>
> > ><br>
> > > That works for me. You must escape the double quotes (") and the dollar<br>
> > > sign ($).<br>
> > ><br>
> > > Best regards,<br>
> > > Marcel Loose.<br>
> > ><br>
> > ><br>
> ><br>
> > Unfortunately, it doesn't work. I already tried escaping the dollar sign<br>
> > and the<br>
> > result in that case is args="".<br>
> ><br>
> > Fred<br>
> ><br>
> ><br>
> > _______________________________________________<br>
> > Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
> ><br>
> > Visit other Kitware open-source projects at<br>
> > <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
> ><br>
> > Please keep messages on-topic and check the CMake FAQ at:<br>
> > <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
> ><br>
> > Follow this link to subscribe/unsubscribe:<br>
> > <a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br>
> ><br>
><br>
<br>
<br>
</div></div></blockquote></div><br></div>