MantisBT - CMake
View Issue Details
0005974CMakeCMakepublic2007-10-27 13:442011-06-06 18:25
mnieber 
David Cole 
normalfeaturealways
closedwon't fix 
 
CMake 2.8.4 
0005974: DONT_INHERIT keyword for ADD_SUBDIRECTORY
I'm working on CSnake (a set of python classes that generate CMake scripts). CSnake knowns for each target which preprocessor defines and include paths are needed. Therefore, I would like to disable the inheritance of preprocessor defines and include paths that happens when ADD_SUBDIRECTORY is executed, for example using:

ADD_SUBDIRECTORY("project2" "myBinFolder" DONT_INHERIT)

In project2's CMakeLists.txt, I would specify all include folders and defines explicitly. This would allow me to get rid of include folders that are only needed by project2's "parent" target, but not by project2.

Thanks in advance!
No tags attached.
Issue History
2007-10-27 13:44mnieberNew Issue
2007-12-17 12:10Bill HoffmanStatusnew => assigned
2007-12-17 12:10Bill HoffmanAssigned To => Ken Martin
2008-02-14 04:30mnieberNote Added: 0010494
2010-12-14 11:27David ColeAssigned ToKen Martin => David Cole
2010-12-14 11:28David ColeNote Added: 0023956
2010-12-14 11:54mnieberNote Added: 0023963
2011-02-01 16:12David ColeNote Added: 0025217
2011-02-01 16:12David ColeStatusassigned => resolved
2011-02-01 16:12David ColeFixed in Version => CMake 2.8.4
2011-02-01 16:12David ColeResolutionopen => won't fix
2011-06-06 18:25David ColeStatusresolved => closed
2011-06-06 18:25David ColeNote Added: 0026682

Notes
(0010494)
mnieber   
2008-02-14 04:30   
Hi, just a small note to let you know I'm still very much interested in this feature! I hope its implementation is not too complicated.
(0023956)
David Cole   
2010-12-14 11:28   
Can't you implement this by yourself by simply not adding any include directories or definitions at the top level?
(0023963)
mnieber   
2010-12-14 11:54   
Usually this is not possible. CSnake generates a project dependency tree that has many levels. Each project in the tree uses ADD_SUBDIRECTORY for its child projects. In the current CMake, once a project has includes/defines, all its (grand)children will also get them (hence the request for DONT_INHERIT).
(0025217)
David Cole   
2011-02-01 16:12   
This request seems too much against the nature of CMake's add_subdirectory and the inheritance of property and variable values that are built-in and automatic.

I think "DONT_INHERIT" would either:
- block some, but not all, inherited values (and it would be confusing to explain why some things are and some things are not inherited)
  * OR *
- block all inherited values, including cache variable values, and surprise some folks by not getting what they expect from their parent directories...

I think "DONT_INHERIT" goes against the grain of what developers have come to expect from CMake.

The goal that you have of not sharing defs and include dirs with other directories may be realized simply by re-organizing your calls to add_definitions, include_directories and add_subdirectory. With the understanding that subdirectories ALWAYS inherit properties and variables from the parent.

Feel free to bring this up on the mailing list for a more inclusive discussion with other opinions involved... but for now, I'm going to resolve this one as "won't fix"
(0026682)
David Cole   
2011-06-06 18:25   
Closing resolved issues that have not been updated in more than 3 months.