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

Alexander Neundorf a.neundorf-work at gmx.net
Thu Aug 23 08:32:00 EDT 2007


On Thursday 23 August 2007 07:34, Simon wrote:
> 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 >>

Oh, it still mentions SUBDIRS().
You should use ADD_SUBDIRECTORY() instead.


> 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?

No.

Bye
Alex


More information about the CMake mailing list