<div dir="ltr">function() introduces a new scope, so if you want changes you make to variables inside the function to be visible outside the function, you need to use set(... PARENT_SCOPE). Alternatively, a macro() does not introduce a new scope, so replacing your function() with a macro() may also yield the behaviour you want (but changing to a macro has other effects, so make sure you read the docs before going down that path). Also note that setting it in one directory does not make it apply to subdirectories as well, in case that matters in your situation.<div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Oct 25, 2016 at 9:42 AM, Tiago Macarios <span dir="ltr"><<a href="mailto:tiagomacarios@gmail.com" target="_blank">tiagomacarios@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 dir="ltr">Hi,<div><br></div><div>Does CMAKE_INCLUDE_CURRENT_DIR need to be set outside of a function?<br></div><div><br></div><div>I have a function where I define an executable "add_executable". This executable uses moc'ed Qt clasees, so I need to set CMAKE_INCLUDE_CURRENT_DIR. It seems like I have to set it from the top level script calling the function. If I set it inside the function the compilation fails with a missing moc file.<br></div><div><br></div><div>Any ideas?</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>Tiago</div></font></span></div>
<br>--<br>
<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" rel="noreferrer" target="_blank">http://www.cmake.org/Wiki/<wbr>CMake_FAQ</a><br>
<br>
Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br>
<br>
CMake Support: <a href="http://cmake.org/cmake/help/support.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/<wbr>support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/<wbr>consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/<wbr>training.html</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/<wbr>opensource/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/cmake" rel="noreferrer" target="_blank">http://public.kitware.com/<wbr>mailman/listinfo/cmake</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr">Craig Scott<br><div>Melbourne, Australia</div><div><a href="https://crascit.com" target="_blank">https://crascit.com</a><br></div></div></div></div></div></div></div>
</div>