I think that you can use an environment variable rather than a normal variable to bypass the normal scoping rules. So:<br><br>set(ENV{foo} "bar")<br><br>will I think allow other CMakeFiles to read it using:<br><br>
$ENV{foo}<br><br>regardless of the sub-directory level. I haven't tried using this so it may not work but I think it should do what you want.<br><br>--<br>Glenn<br><br><br><div class="gmail_quote">On 19 May 2011 13:05, Eric Noulard <span dir="ltr"><<a href="mailto:eric.noulard@gmail.com">eric.noulard@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">2011/5/19 J.S. van Bethlehem <<a href="mailto:j.s.van.bethlehem@astro.rug.nl">j.s.van.bethlehem@astro.rug.nl</a>>:<br>
<div class="im">><br>
> Hello Eike,<br>
><br>
> Thanks a lot for your reply. I have actually been thinking in the same<br>
> direction. I have one problem though: how can you make a truly global<br>
> variable in CMake? Whenever you do something to a variable in a directory<br>
> that is added using add_subdirectory(), those changes don't propagate to the<br>
> current directory<br>
> (well, one could use the PARENT_SCOPE option to set() in the sub-directory,<br>
> but then I won't be able to test that sub-directory seperately because then<br>
> CMake will err that there is no such scope)<br>
><br>
> How do you deal with this?<br>
<br>
</div>I think, that's why Eike uses **property** and not variable.<br>
<br>
Property may be at "GLOBAL" scope:<br>
<br>
set_property(<GLOBAL |<br>
DIRECTORY [dir] |<br>
TARGET [target1 [target2 ...]] |<br>
SOURCE [src1 [src2 ...]] |<br>
TEST [test1 [test2 ...]] |<br>
CACHE [entry1 [entry2 ...]]><br>
[APPEND]<br>
PROPERTY <name> [value1 [value2 ...]])<br>
<br>
Set one property on zero or more objects of a scope. The first<br>
argument determines the scope in which the property is set. It must<br>
be one of the following:<br>
<br>
GLOBAL scope is unique and does not accept a name.<br>
...<br>
<font color="#888888">--<br>
Erk<br>
Membre de l'April - « promouvoir et défendre le logiciel libre » -<br>
<a href="http://www.april.org" target="_blank">http://www.april.org</a><br>
</font><div><div></div><div class="h5">_______________________________________________<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/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/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>
</div></div></blockquote></div><br>