[CMake] Interference between siblings

Brad King brad.king at kitware.com
Fri Oct 8 15:26:35 EDT 2004


Weiguang Guan wrote:

> Hi CMake users,
> 
> Variables, include paths, library paths, etc. are inherited from top-level 
> directory to subdirectories. If we follow this philosophy sibling 
> directories shouldn't affect one another. However, I find this is not the 
> case. 
> 
> I have a source tree, which looks like
> 
> src 
>     / libraries 
> 		/ vtk
> 		/ itk
> 		/ ...
>     / apps	
> 		/ app1 
> 		/ app2
> 
> where CMakeLists.txt in a non-leaf directory contains nothing but 
> SUBDIRS(...). Then I create a directory 'build' to be the root of build 
> tree. In the build directory I ccmake ....../src, then the build tree is 
> generated, which looks like
> 
> build
>     / libraries
>                 / vtk
>                 / itk
>                 / ...
>     / apps
>                 / app1
>                 / app2
> 
> Take the Makefile for app1 as an example. It is different from the 
> Makefile generated by using ccmake ....../src/apps/app1.

This is because CMake never looks above the directory specified as the 
top level source tree.  In your example when you specify src/apps/app1 
as the source tree then it does not inherit any settings from 
src/CMakeLists.txt or src/apps/CMakeLists.txt.  When you specify src as 
the source tree then app1 gets all those settings.

-Brad



More information about the CMake mailing list