Try this:<br>MACRO(BAR)<br>&nbsp;&nbsp; SET(bar_ARGV0 &quot;${ARGV0}&quot;)<br>&nbsp;&nbsp; MESSAGE(&quot;bar_ARGV0 = ${bar_ARGV0}&quot;)<br>&nbsp;&nbsp; SET(ARGV0_NAME bar_ARGV0)<br>&nbsp;&nbsp; MESSAGE(&quot;bar_ARGV0 = ${${bar_ARGV0_NAME}}&quot;)<br>ENDMACRO(BAR)
<br><br>I&#39;m not *the* expert to explain this behavior, but I can tell you this:<br>When a macro is called, it is evaluated in its entirety in terms of variable substitutions. In other words, the text of the macro is scanned and variable substitutions for ${ARG*} and any formally named macro parameters are done prior to executing the first line of the macro. The only &quot;variables&quot; that exist as you execute are those that existed prior to calling the macro plus those that you explicitly set within the macro. The formal parameters and the ARG* values are not variables. If they were, you could not achieve macros calling macros without having local scope to macro variables.
<br><br>So, in your example, doing a SET as the first line with &quot;${ARGV0}&quot; as the value is substituted prior to running and it works as you expect. In your original example, ${ARGV0} only appears inside a MESSAGE command, and there is no variable named that, so you cannot access it via double indirection with ARGV0 as a variable name,,,
<br><br>This has the one nice effect that the macro parameters are hidden and so do not pollute the CMake variable space, but it does take some getting used to... (as you were suggesting in your other thread -- it would be nice to have a mechanism to achieve variables local in scope to a macro) -- Perhaps you could see if it&#39;s already a feature request in CMake&#39;s bug tracker? If not, feel free to add a feature request for macro local variables.
<br><br><br>HTH,<br>David<br><br><br><div><span class="gmail_quote">On 7/27/07, <b class="gmail_sendername">Christian Convey</b> &lt;<a href="mailto:christian.convey@gmail.com">christian.convey@gmail.com</a>&gt; wrote:</span>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Could someone please explain why this code works:<br><br>SET(FOO 10)<br>SET(FOONAME FOO)<br>
MESSAGE(&quot;FOO = ${${FOONAME}}&quot;)<br><br>but this code does not?<br><br>MACRO(BAR)<br>&nbsp;&nbsp; MESSAGE(&quot;ARGV0 = ${ARGV0}&quot;)<br>&nbsp;&nbsp; SET(ARGV0_NAME ARGV0)<br>&nbsp;&nbsp; MESSAGE(&quot;ARGV0 = ${${ARGV0_NAME}}&quot;)<br>ENDMACRO(BAR)
<br><br>BAR(123)<br><br>In the first block of code, &quot;FOO = 10&quot; is printed to the console when<br>I run this through CMake.<br><br>But in the second block of code (using the &quot;BAR&quot; macro), I get this output:
<br>ARGV0 = 123<br>ARGV0 =<br><br>So why can I dynamically construct the variable name in the first<br>example (&quot;FOO = 10&quot;), but in the second example (&quot;ARGV0 = &quot;) ?<br><br>Thanks,<br>Christian<br>_______________________________________________
<br>CMake mailing list<br><a href="mailto:CMake@cmake.org">CMake@cmake.org</a><br><a href="http://www.cmake.org/mailman/listinfo/cmake">http://www.cmake.org/mailman/listinfo/cmake</a><br></blockquote></div><br>