[CMake] Handling of include directories when recursing sub-directories

Simon sjhoffe at gmail.com
Thu Aug 23 07:34:02 EDT 2007


Hi,

I'm looking to use CMake in our production development environment. We
are producing a multi-component library for release and are revising
our build methodology. CMake looks like it may do what we need.

I have a question:

To quote http://www.cmake.org/HTML/WritingCMakeLists.html :

<< begin quote >>
CMake works recursively, descending from the current directory into
any subdirectories listed in the SUBDIRS command. The command SET is
used for setting a variable, in this case to a list of source files.

<<snip>>

INCLUDE_DIRECTORIES()
LINK_DIRECTORIES()
LINK_LIBRARIES()
TARGET_LINK_LIBRARIES()

These commands define directories and libraries used to compile source
code and build executables. An important feature of the commands
listed above is that are inherited by any subdirectories. That is, as
CMake descends through a directory hierarchy (defined by SUBDIRS())
these commands are expanded each time a definition for a command is
encountered.
<< end quote >>

If I add an additional include path using INCLUDE_DIRECTORIES in a
CMakeLists.txt buried in a subdirectory, when CMake is finished
processing in that subdirectory and comes back up to the parent
CMakeLists.txt, is the additional include path still in effect?

I would like additional include directories added in lower level
subdirectories to be discarded when CMake is finished processing that
directory.

That way I can build a tree of self-contained modules, some of which
are quite complex in their own right, but which can be recursively
linked into one library with a single top-level cmake and make
combination.

Thanks for you help,

Simon


More information about the CMake mailing list