[CMake] Feature: optional targets that respect dependencies?

Hendrik Sattler post at hendrik-sattler.de
Mon Aug 13 17:58:55 EDT 2007


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.

HS


More information about the CMake mailing list