[CMake] CMAKE_CURRENT_SOURCE_DIR showing up in include directories

Andreas Pakulat apaku at gmx.de
Fri Jun 8 03:18:05 EDT 2012


Hi,

On Fri, Jun 8, 2012 at 3:14 AM, Robert Dailey <rcdailey.lists at gmail.com>wrote:

> I think I might know what it is...
>
> I do the following:
>
> include_directories( Z )
> add_library( A )
> include_directories( A ) # Include "A"'s include directory
> add_library(B) # B depends on A, and thus includes its header directory
>
> My assumption was that, at configuration time, a snapshot of the current
> include directories is taken and used, so thus any further ones that are
> added will not affect previously created targets in the same directory.
> However, apparently directory properties are processed at generation time,
> so this is why I'm seeing this behavior.
>
> Can anyone confirm?
>

Basically yes. I don't actually know the internals of CMake but from what I
understood, include_directories is executed during the configuration phase
and sets a directory-property. The creation of the Makefile/VS
file/whatever is done later and simply reads this directory property. So
all targets in a directory will use the same include dirs.

Luckily in 2.8.8 CMake gained the ability to set include-directories per
target, so you can achieve what
you want if you run require 2.8.8 and set the INCLUDE_DIRECTORIES target
property.

Andreas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120608/61b6434f/attachment.htm>


More information about the CMake mailing list