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.
On Tue, Oct 25, 2016 at 9:42 AM, Tiago Macarios <tiagomacar...@gmail.com> wrote: > Hi, > > Does CMAKE_INCLUDE_CURRENT_DIR need to be set outside of a function? > > 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. > > Any ideas? > > Tiago > > -- > > Powered by www.kitware.com > > Please keep messages on-topic and check the CMake FAQ at: > http://www.cmake.org/Wiki/CMake_FAQ > > Kitware offers various services to support the CMake community. For more > information on each offering, please visit: > > CMake Support: http://cmake.org/cmake/help/support.html > CMake Consulting: http://cmake.org/cmake/help/consulting.html > CMake Training Courses: http://cmake.org/cmake/help/training.html > > Visit other Kitware open-source projects at http://www.kitware.com/ > opensource/opensource.html > > Follow this link to subscribe/unsubscribe: > http://public.kitware.com/mailman/listinfo/cmake > -- Craig Scott Melbourne, Australia https://crascit.com
-- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake