[CMake] how to inherit includes from other directories

Glenn Coombs glenn.coombs at gmail.com
Wed Sep 7 07:36:28 EDT 2011


Could you not create a file in each subdirectory called something like
header-deps.cmake ?  This file would contain the include_directory()
commands necessary for using this module, plus include() commands of other
modules that it depends on.  So for your example:

# utils/b/header-deps.cmake
include_directories(...)
include(${CMAKE_SOURCE_DIR)/utils/a/header-deps.cmake)

# utils/a/header-deps.cmake
include_directories(${CMAKE_SOURCE_DIR}/common/foo)

Then you can just do include(${CMAKE_SOURCE_DIR}/utils/b/header-deps.cmake)
and it will add everything that B needs including all its dependencies.

--
Glenn


On 7 September 2011 06:53, Raymond Wan <r.wan at aist.go.jp> wrote:

> Hi Victor,
>
>
> On Wed, Sep 7, 2011 at 05:39, Victor Yankee
> <victor.whiskey.yankee at gmail.com> wrote:
> > There may 3 or 4 levels. At the top level, I would very much like to
> avoid
> > needing to know all the dependencies at all the lower levels and
> > exhaustively listing each one in an  'include_directories()' command.
> >
> > If utils/B.h needs utils/A.h which needs foo/Z.h, then in my top-level
> > directory (that only needs to know about B.h)  what does its
> CMakeLists.txt
> > look like? I would like to just be add_includes(utils/B) and have cmake
> > figure out it also needs utils/A and foo.
>
>
> I see what you mean now.  David's reply says it better than I ever could...
>
> The only thing I can add is that I have the same problem as you.  :-)
> Many include_directories (), even for those that are more than one
> degree of separation away...  I've since given up and just have a long
> list of include_directories ()...
>
> Ray
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20110907/3386afde/attachment.htm>


More information about the CMake mailing list