[CMake] How to not evaluate variable names ?

2009-09-30 Thread fred . antares
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 ?

Thanks

___
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


Re: [CMake] How to not evaluate variable names ?

2009-09-30 Thread Jeroen Dierckx
On Wed, Sep 30, 2009 at 8:32 AM, fred.anta...@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 ?


Are you using configure_file? Because then you could use the @ONLY option to
ensure only variables of the form @VARNAME@ are replaced.

See http://cmake.org/cmake/help/cmake2.6docs.html#command:configure_file

Greetz,
JeDi




 Thanks

 ___
 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

___
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

Re: [CMake] How to not evaluate variable names ?

2009-09-30 Thread fred . antares
Quoting Jeroen Dierckx jeroen.dier...@gmail.com:

 On Wed, Sep 30, 2009 at 8:32 AM, fred.anta...@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 ?
 

 Are you using configure_file? Because then you could use the @ONLY option to
 ensure only variables of the form @VARNAME@ are replaced.

 See http://cmake.org/cmake/help/cmake2.6docs.html#command:configure_file

 Greetz,
 JeDi



No, I'm not using configure_file, at least not in that case, and given the
amount of scripts already existing, it would be a real pain to change all of
them to use @ for variables...

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


Re: [CMake] How to not evaluate variable names ?

2009-09-30 Thread Marcel Loose
On Wed, 2009-09-30 at 09:28 +0200, fred.anta...@free.fr wrote:
 Quoting Jeroen Dierckx jeroen.dier...@gmail.com:
 
  On Wed, Sep 30, 2009 at 8:32 AM, fred.anta...@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.


___
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


Re: [CMake] How to not evaluate variable names ?

2009-09-30 Thread David Cole
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.anta...@free.fr wrote:

 Quoting Marcel Loose lo...@astron.nl:

  On Wed, 2009-09-30 at 09:28 +0200, fred.anta...@free.fr wrote:
   Quoting Jeroen Dierckx jeroen.dier...@gmail.com:
  
On Wed, Sep 30, 2009 at 8:32 AM, fred.anta...@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

___
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

Re: [CMake] How to not evaluate variable names ?

2009-09-30 Thread fred . antares
The problem is I'm working on quite a big project, and it was not written
initially by me. I don't know about the FILE(WRITE, but here's what I'm doing:
- In the CMakelists, I'm calling a macro with one of the parameters being what I
want in my attribute (in that case ${do_not_evaluate}).
- This macro adds the attribute to a specific source group
- The source group is parsed and interpreted by custom code that was added to
CMake for our own generation needs
- The arg ends up being added to a Tiny XML element
- The XML file write is done from the custom code, by calling Write on the Tiny
XML hierarchy

The CMake version is 2.4.8, but customized with our own generators.

Maybe the simpler thing, given the case and the lack of a direct solution, would
be to add a specific string to the attribute, signaling to the code that it
should be replaced ?

Fred

Quoting David Cole david.c...@kitware.com:

 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.anta...@free.fr wrote:

  Quoting Marcel Loose lo...@astron.nl:
 
   On Wed, 2009-09-30 at 09:28 +0200, fred.anta...@free.fr wrote:
Quoting Jeroen Dierckx jeroen.dier...@gmail.com:
   
 On Wed, Sep 30, 2009 at 8:32 AM, fred.anta...@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
 



___
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


Re: [CMake] How to not evaluate variable names ?

2009-09-30 Thread David Cole
so if you have this:  macro(blah arg1)
message(==${arg1}==)
  endmacro(blah)

  blah(${do_not_evaluate})
  blah(\${do_not_evaluate})
  blah(\\\${do_not_evaluate})

you should see:


==${do_not_evaluate}==

I'm using CMake 2.6.4 to get these results. I think 2.4.8 should give you
the same...

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.

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...)

If you could post some code (or simplify it) others may be able to offer
some more helpful suggestions.


HTH,
David


On Wed, Sep 30, 2009 at 8:09 AM, fred.anta...@free.fr wrote:

 The problem is I'm working on quite a big project, and it was not written
 initially by me. I don't know about the FILE(WRITE, but here's what I'm
 doing:
 - In the CMakelists, I'm calling a macro with one of the parameters being
 what I
 want in my attribute (in that case ${do_not_evaluate}).
 - This macro adds the attribute to a specific source group
 - The source group is parsed and interpreted by custom code that was added
 to
 CMake for our own generation needs
 - The arg ends up being added to a Tiny XML element
 - The XML file write is done from the custom code, by calling Write on the
 Tiny
 XML hierarchy

 The CMake version is 2.4.8, but customized with our own generators.

 Maybe the simpler thing, given the case and the lack of a direct solution,
 would
 be to add a specific string to the attribute, signaling to the code that it
 should be replaced ?

 Fred

 Quoting David Cole david.c...@kitware.com:

  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.anta...@free.fr wrote:
 
   Quoting Marcel Loose lo...@astron.nl:
  
On Wed, 2009-09-30 at 09:28 +0200, fred.anta...@free.fr wrote:
 Quoting Jeroen Dierckx jeroen.dier...@gmail.com:

  On Wed, Sep 30, 2009 at 8:32 AM, fred.anta...@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
  
 



___
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

Re: [CMake] How to not evaluate variable names ?

2009-09-30 Thread fred . antares
Ok, maybe I didn't escape enough when testing... Anyway, I've just gone with the
code way, tagging my variable and replacing it in my custom generator in that
specific case, and it's working nicely, so that will do for now...

And moreover, it saves me from simplifying and posting code, 'cause it's really
a mess ! (I'm not sure I completely understand it myself :/)

Thanks for the help,
Fred

Quoting David Cole david.c...@kitware.com:

 so if you have this:  macro(blah arg1)
 message(==${arg1}==)
   endmacro(blah)

   blah(${do_not_evaluate})
   blah(\${do_not_evaluate})
   blah(\\\${do_not_evaluate})

 you should see:
 
 
 ==${do_not_evaluate}==

 I'm using CMake 2.6.4 to get these results. I think 2.4.8 should give you
 the same...

 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.

 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...)

 If you could post some code (or simplify it) others may be able to offer
 some more helpful suggestions.


 HTH,
 David


 On Wed, Sep 30, 2009 at 8:09 AM, fred.anta...@free.fr wrote:

  The problem is I'm working on quite a big project, and it was not written
  initially by me. I don't know about the FILE(WRITE, but here's what I'm
  doing:
  - In the CMakelists, I'm calling a macro with one of the parameters being
  what I
  want in my attribute (in that case ${do_not_evaluate}).
  - This macro adds the attribute to a specific source group
  - The source group is parsed and interpreted by custom code that was added
  to
  CMake for our own generation needs
  - The arg ends up being added to a Tiny XML element
  - The XML file write is done from the custom code, by calling Write on the
  Tiny
  XML hierarchy
 
  The CMake version is 2.4.8, but customized with our own generators.
 
  Maybe the simpler thing, given the case and the lack of a direct solution,
  would
  be to add a specific string to the attribute, signaling to the code that it
  should be replaced ?
 
  Fred
 
  Quoting David Cole david.c...@kitware.com:
 
   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.anta...@free.fr wrote:
  
Quoting Marcel Loose lo...@astron.nl:
   
 On Wed, 2009-09-30 at 09:28 +0200, fred.anta...@free.fr wrote:
  Quoting Jeroen Dierckx jeroen.dier...@gmail.com:
 
   On Wed, Sep 30, 2009 at 8:32 AM, fred.anta...@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
   
  
 
 
 



___
Powered