[CMake] nested replacement with @@

Eric Clark eclark at ara.com
Wed Apr 10 15:51:03 EDT 2013


Nico,

I had this same problem at one point in time, but was able to change it to the ${...} syntax which works beautifully. I know that you cannot use this syntax, but I will tell you that I did find a work-around for the nested @...@ syntax. The workaround is to run configure_file on the file twice. The nested @...@ symbols will always be replaced from the inside out which is the behavior that you want, you just have to run configure_file on the file for as many nests that you have. If the deepest nest you have is two nests, then you only need to run configure_file twice. I know this is kind of a kludge to fix it, but it does work from my experience...

Hope this helps...
Eric

> -----Original Message-----
> From: cmake-bounces at cmake.org [mailto:cmake-bounces at cmake.org] On
> Behalf Of Nico Schlömer
> Sent: Wednesday, April 10, 2013 12:55 PM
> To: cmake
> Subject: [CMake] nested replacement with @@
> 
> Hi all,
> 
> in a ProjectContfigTemplate.cmake.in file, I'd like to have variables such as
> ${${PROJECT_NAME}_VERSION}. In ${}-syntax, the nesting is recognized
> properly, and this string would be replaced by, e.g., "2.1".
> 
> I know need to have ${}-variables in the output file, so I tried to switch to the
> @-syntax. Replacing the above line by
> 
> @@PROJECT_NAME at _VERSION@
> 
> doesn't work however: The output file contains
> 
> @Myproject_VERSION@
> 
> i.e., only the inner variable was replaced.
> 
> How to fix this?
> 
> Cheers,
> Nico
> --
> 
> 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


More information about the CMake mailing list