[cmake-developers] Adding argument "OPTIONAL" to find_package() and add_subdirectory

Brad King brad.king at kitware.com
Wed Jun 8 15:42:16 EDT 2011


On 6/8/2011 2:08 PM, Alexander Neundorf wrote:
> This would make the options available for cmake-based projects more 
> consistent.
> This issue comes up regularly from new users.

The option() command adds options.  The add_subdirectory command
adds subdirectories.  The find_package command finds packages.
These are well-defined primitives.  I don't want to change this.

  http://en.wikipedia.org/wiki/Law_of_Demeter

> So, I don't see a reason why such an option should not be the default 
> behaviour and why I should rely on an external extension.

With that goal in mind I see no reason not to do this in a module
that comes with CMake:

  include(OptionalFindPackage)
  optional_find_package(XYZ)

This will keep the additional features out of the main command and
provide a separate place to document them.  If it turns out that the
way the feature is implemented isn't that clean we can easily create
a new macro with a new name.

-Brad



More information about the cmake-developers mailing list