[CMake] Feature: optional targets that respect dependencies?

Christian Convey christian.convey at gmail.com
Tue Aug 14 10:53:27 EDT 2007


On 8/13/07, Hendrik Sattler <post at hendrik-sattler.de> wrote:
> Am Montag 13 August 2007 21:26 schrieb Christian Convey:
> > Is the following something that should be added to CMake?
> >
> > My project has about 70 targets: about 20 libraries and 50 apps.
> >
> > I'd like to make the building of any particular target be optional, as
> > expressed by the OPTION(...) command.  However, if I try to build an
> > app that depends on a library target the user has specified to NOT
> > build, there's an obvious problem at link time.
> >
> > CMake knows about all the dependencies between build targets.  Should
> > we do something like the following, in a future version of CMake? :
> >
> > ADD_EXECUTABLE(...
> >     ...
> >    [ OPTIONAL  { FORCE_DEPENDENCY_BUILDS |
> > WARN_IF_DEPENDENCIES_NOT_BUILT } [ option-variable-name
> > [option-default-value] ] ]
> >    ...
> >    )
>
> It is a bug in you build rules if you run into such a situation.
> You can either:
> 1. force enabling of options that are needed by others
> 2. only offer option when all its requirements are built
>
> With some thought, you only have to specify the dependencies once. And you
> don't need any addition to ADD_EXECUTABLE for that.

CMake is a language designed to make common build-related tasks
easier.  The language contains a number of constructs that could be
implemented by CMake users, but that exist as a matter of convenience
and to permit cmake list files to be short, expressive, and readable.

You are correct that I can implement 1. or 2. by hand.  However, doing
so will add complexity to my cmake files, which I would like to avoid
if possible.

So my question was: do enough people feel that the language would be
improved by including the feature I mentioned.  I believe that such a
feature would benefit my work, but I don't know how many other cmake
users would also benefit.  That's a question that I still consider
open.

 - Christian


More information about the CMake mailing list