On 17 June 2015 at 12:28, Robert Dailey <rcdailey.li...@gmail.com> wrote: > Is there a way to only take (recursively) the include directiories from > a target or set of targets? I know that include directories propagate > when passing targets to target_link_libraries(), but I do not want to > link the libs; I only want the include directories. > > How can I do this? Thanks.
I presume recursively you mean propagating the required include directories between targets rather anything to do recursively handling directories. As you mentioned include directories do propagate but this only happens under certain conditions (when using PUBLIC or INTERFACE scopes). I don't know of a way of doing it without target_link_libraries but if it is necessary for you to do this it sounds like you have bigger problems relating to the way you have your project header files organised. The approach I use for include directories is to have all includes for the project rooted in a single include directory in the source tree and have all includes relative to that directory. Then if I you ``` include_directories(${CMAKE_SOURCE_DIR}/include) include_directories(${CMAKE_BINARY_DIR}/include) # for generated header files ``` in the root of the project you never need to set include paths anywhere else for sources that are in your project tree. E.g. if there is header file in ${CMAKE_SOURCE_DIR}/include/project/moduleA/interface.h then in the sources this is included as #include "project/moduleA/interface.h" (note there are never relative header file includes). This is the approach that the LLVM project uses which is very simple and very clean (take a look at the sources). This also works very well for installing your header files, the contents of ${CMAKE_SOURCE_DIR} just need to be copied into /usr/include . -- 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