[CMake] INCLUDE_DIRECTORIES with SUBDIRS

Brad King brad.king at kitware.com
Fri Dec 9 09:46:17 EST 2005


Stefan Kowski wrote:
> Hi,
> 
> I am using CMake 2.0.6 on Windows and have a problem with the
> INCLUDE_DIRECTORIES statement.
> 
> I try to compile two shared library (referred to as lib1 and lib2), each of
> them using a component X, but in different versions. Each library has its 
> own CMakeLists.txt that includes X's include directory. So lib1 includes 
> X1/include, lib2 includes X2/include.
> 
> simplified directory structure:
> 
>   CMakeLists.txt         SUBDIRS(lib1 lib2)
>   lib1/
>      CMakeLists.txt      INCLUDE_DIRECTORIES(X1/include)
>   lib2/
>      CMakeLists.txt      INCLUDE_DIRECTORIES(X2/include)
>   
> In the generated .dsw files for Visual Studio 6, I see that lib1 includes
> X1/include, but lib2 includes X1/include and X2/include, breaking the
> build of lib2 as wrong headers are included.
> 
> As I checked the documentation, I found that the INCLUDE_DIRECTORIES 
> expands a 'global' include path with each statement, even across sibling 
> directories (link: http://www.cmake.org/HTML/WritingCMakeLists.html).

It shouldn't be available across sibling directories.  I don't think the 
documentation at that link claims this is the case.  It just says that 
all child directories will inherit the include path from their parents.

This may be a bug in the VS generator.  Please download CMake 2.2.3 and 
see if it still occurs.  If so then submit a bug report here:

http://www.cmake.org/Bug

Thanks,
-Brad


More information about the CMake mailing list