Let me ask this,<div><br></div><div>What would be the parent of a function located in the root CMakeLists file but called from a subordinate CMakeLists file?<br clear="all"><div><br></div><div>---------</div>Robert Dailey<br>

<br><br><div class="gmail_quote">On Thu, Oct 20, 2011 at 11:55 AM, Michael Wild <span dir="ltr">&lt;<a href="mailto:themiwi@gmail.com">themiwi@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On 10/20/2011 05:41 PM, Robert Dailey wrote:<br>
&gt; On Thu, Oct 20, 2011 at 2:36 AM, Rolf Eike Beer &lt;<a href="mailto:eike@sf-mail.de">eike@sf-mail.de</a><br>
</div><div><div></div><div class="h5">&gt; &lt;mailto:<a href="mailto:eike@sf-mail.de">eike@sf-mail.de</a>&gt;&gt; wrote:<br>
&gt;<br>
&gt;     &gt; I have a function defined very high up in the directory tree at<br>
&gt;     the root<br>
&gt;     &gt; CMakeLists file. Several levels below it, I have another<br>
&gt;     CMakeLists file<br>
&gt;     &gt; that I call that function from.<br>
&gt;     &gt;<br>
&gt;     &gt; The function sets CMAKE_MFC_FLAG to 2. I notice that this flag gets<br>
&gt;     &gt; ignored<br>
&gt;     &gt; when it is set inside of the function in question. If I set the flag<br>
&gt;     &gt; outside<br>
&gt;     &gt; of the function, in the lowest level CMakeLists file, it works. This<br>
&gt;     &gt; property seems somehow tied to the directory itself, but I can&#39;t<br>
&gt;     figure<br>
&gt;     &gt; out<br>
&gt;     &gt; if this is a feature or a bug.<br>
&gt;     &gt;<br>
&gt;     &gt; This behavior isn&#39;t very flexible as I&#39;d like to make the details of<br>
&gt;     &gt; configuring an MFC compatible project transparent to the lower level<br>
&gt;     &gt; CMakeLists scripts. Hiding away the flag and how it needs to be<br>
&gt;     set is a<br>
&gt;     &gt; big<br>
&gt;     &gt; part of this, but I can&#39;t do it.<br>
&gt;     &gt;<br>
&gt;     &gt; Anyone know how I can make this work?<br>
&gt;<br>
&gt;     A function creates a new variable scope, i.e. everything you set in<br>
&gt;     there<br>
&gt;     will be reset once you leave the function. Have a look at SET(...<br>
&gt;     PARENT_SCOPE) for this.<br>
&gt;<br>
&gt;<br>
&gt; Not even that worked, unfortunately.<br>
&gt;<br>
&gt; Basically from my function I do:<br>
&gt;<br>
&gt; set( CMAKE_MFC_FLAG 2 )<br>
&gt; add_executable( ... )<br>
&gt;<br>
&gt; Since I&#39;m setting it right before the add_executable() call, I would<br>
&gt; think that scope has nothing to do with it.<br>
<br>
</div></div>No, the add_executable() call does not evaluate the variable. It only<br>
gets evaluated *after* the processing of the current CMakeLists.txt<br>
file. If using set(CMAKE_MFC_FLAG 2 PARENT_SCOPE) really doesn&#39;t work,<br>
IMHO that would be a bug. The only work-around would be to use a macro<br>
instead (where you don&#39;t need the PARENT_SCOPE at all).<br>
<font color="#888888"><br>
Michael<br>
</font><div><div></div><div class="h5"><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/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></div>