[CMake] problem with ADD_SUBDIRECTORY always inheriting all settings

John Drescher drescherjm at gmail.com
Tue Feb 1 17:21:56 EST 2011


On Tue, Feb 1, 2011 at 5:12 PM, Maarten Nieber <hallomaarten at yahoo.com> wrote:
> Hi everybody,
> I´m mailing to find out what the community thinks of my feature request
> (http://public.kitware.com/Bug/view.php?id=5974), which was unfortunately
> rejected, and maybe come up with a better idea that serves the same goal.
> However, first I want to say that I appreciate the effort that the CMake
> team is putting in this free software. If my feature request really doesn't
> make it into CMake, so be it :-)
> The plea that I would like to make is that the core functionality of CMake
> is to set up the compilation environment, and therefore CMake should avoid
> restrictions on which environments you can create. The current problem I see
> with ADD_SUBDIRECTORY is that you can create a solution with all your
> projects, but it does not give you full control of your environment: child
> projects will always inherit all settings from parent projects, including
> the ones they don't need or don't want.
> A workaround was proposed: let all child projects depend on an empty parent
> project. This however will not work, because I'm depending on
> ADD_SUBDIRECTORY to create the >real< dependency structure of my project, as
> this structure will affect build order and linker dependencies (in fact, I
> don't think that ADD_SUBDIRECTORY should create a linker dependency either,
> but this is a related but different issue).

A simple solution is to put the ADD_SUBDIRECTORY in the parent before
you make any settings. I do this with all my library subprojects.


John


More information about the CMake mailing list