Hi François, <br>
<br>
Would the use of function be helpful ?<br>
<br>
See <a href="http://www.cmake.org/cmake/help/cmake-2-8-docs.html#command:function">http://www.cmake.org/cmake/help/cmake-2-8-docs.html#command:function</a><br>
and <a href="http://www.cmake.org/cmake/help/cmake-2-8-docs.html#command:set">http://www.cmake.org/cmake/help/cmake-2-8-docs.html#command:set</a><br>
<br>
"If PARENT_SCOPE is present, the variable will be set in the scope above
the current scope. Each new directory or function creates a new scope.
This command will set the value of a variable into the parent directory
or calling function (whichever is applicable to the case at hand)."<br>
<br>
I created a small example showing that variable set within a function
don't interfere with the parent scope if not explicitly required. <br>
<br>
<span style="font-family:courier new,monospace">git clone git://<a href="http://gist.github.com/1888836.git">gist.github.com/1888836.git</a></span><br style="font-family:courier new,monospace">
<span style="font-family:courier new,monospace">cmake -P 1888836/cmake-illustrate-function-scope.cmake</span><br>
<br>
Hth<br>
Jc<br><br><div class="gmail_quote">On Wed, Feb 22, 2012 at 7:07 PM, François Mauger <span dir="ltr"><<a href="mailto:mauger@lpccaen.in2p3.fr">mauger@lpccaen.in2p3.fr</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi CMakers,<br>
<br>
In november 2007, there was a long thread titled "lexical scoping".<br>
The discussion was really interesting and was suggesting that some<br>
"local scoping" features for variables could be implemented in CMake...<br>
particularly from macros, which are probably the practical case that causes most issues when users implement several nested levels of macro invocations with many intermediate temporary variables that unfortunately aggregate in the global scope. It is really easy to face such problem in a rather large project driven with Cmake (a dependency driver invoking the find_package command in a foreach loop must be done from a macro AFAIK).<br>
Unless I missed something in the jungle of CMake threads and doc, I'm afraid I was not able to find some satisfactory solution other than hacks (using very long variable names to "emulate" some pseudo local scopes). this is tedious and bug prone.<br>
<br>
Browsing the last 4 years of archives and some additionnal docs, I was not able to find a single trace of such new feature : implementing "local scoping" in CMake (whatever "local scoping" could rationally mean).<br>
<br>
What is the current situation on users' side ? Is there any pressure for "local scoping" ? Maybe too few people ask for it so CMake developpers do not consider it as a priority... or no clear definition<br>
of "local scoping" has been patterned ?<br>
more what is the view of the CMake devel team ? do they consider this idea as a good one or not ?<br>
<br>
Thanks a lot for hints and advices.<br>
<br>
Best regards<br>
frc<br>
-- <br>
François Mauger<br>
LPC Caen-CNRS/IN2P3-UCBN-ENSICAEN<br>
Département de Physique -- Université de Caen Basse-Normandie<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 <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/<u></u>opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/<u></u>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/<u></u>listinfo/cmake</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>+1 919 869 8849<br><br>