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"><<a href="mailto:themiwi@gmail.com">themiwi@gmail.com</a>></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>
> On Thu, Oct 20, 2011 at 2:36 AM, Rolf Eike Beer <<a href="mailto:eike@sf-mail.de">eike@sf-mail.de</a><br>
</div><div><div></div><div class="h5">> <mailto:<a href="mailto:eike@sf-mail.de">eike@sf-mail.de</a>>> wrote:<br>
><br>
> > I have a function defined very high up in the directory tree at<br>
> the root<br>
> > CMakeLists file. Several levels below it, I have another<br>
> CMakeLists file<br>
> > that I call that function from.<br>
> ><br>
> > The function sets CMAKE_MFC_FLAG to 2. I notice that this flag gets<br>
> > ignored<br>
> > when it is set inside of the function in question. If I set the flag<br>
> > outside<br>
> > of the function, in the lowest level CMakeLists file, it works. This<br>
> > property seems somehow tied to the directory itself, but I can't<br>
> figure<br>
> > out<br>
> > if this is a feature or a bug.<br>
> ><br>
> > This behavior isn't very flexible as I'd like to make the details of<br>
> > configuring an MFC compatible project transparent to the lower level<br>
> > CMakeLists scripts. Hiding away the flag and how it needs to be<br>
> set is a<br>
> > big<br>
> > part of this, but I can't do it.<br>
> ><br>
> > Anyone know how I can make this work?<br>
><br>
> A function creates a new variable scope, i.e. everything you set in<br>
> there<br>
> will be reset once you leave the function. Have a look at SET(...<br>
> PARENT_SCOPE) for this.<br>
><br>
><br>
> Not even that worked, unfortunately.<br>
><br>
> Basically from my function I do:<br>
><br>
> set( CMAKE_MFC_FLAG 2 )<br>
> add_executable( ... )<br>
><br>
> Since I'm setting it right before the add_executable() call, I would<br>
> 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't work,<br>
IMHO that would be a bug. The only work-around would be to use a macro<br>
instead (where you don'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>