cmake-basis / legacy

Legacy CMake BASIS project for versions 3.2 and older. For newer versions, go to
https://github.com/cmake-basis/BASIS
Other
13 stars 11 forks source link

basis_find_package does not support OPTIONAL_COMPONENTS #551

Closed schuhschuh closed 8 years ago

schuhschuh commented 8 years ago

The basis_find_package macro does not support the (new?, available already in CMake 2.8.12) OPTIONAL_COMPONENTS arguments. Thus far it has not been needed for BASIS projects, though, because it uses find_package(<Pkg> COMPONENTS <comp1> <comp2> ...) without the REQUIRED option ?!? Need to look into this again in more detail. In any case, basis_find_package should also understand the OPTIONAL_COMPONENTS option.

schuhschuh commented 8 years ago

When the REQUIRED option is not given, i.e., <PKG>_FIND_REQUIRED is not set to TRUE (and not even defined), no error is raised when one of the components is not found, but <PKG>_FOUND may also be set to FALSE after the find_package, because for all COMPONENTS, <PKG>_FIND_REQUIRED_<COMP> is TRUE.

But, for the OPTIONAL_DEPENDS in BasisProject.cmake, this is intended. Only when all components are found, the optional dependency is considered to be fulfilled. The <PKG>_FOUND variable is set to TRUE when the package has previously been found with a different set of (required) components. Therefore no need for OPTIONAL_COMPONENTS in this case.

The basis_find_package macro should still consider it, though, and pass it on to find_package.

schuhschuh commented 8 years ago

A change included in commit 6b35397 is that basis_find_package accepts now all arguments that also find_package knows. It simply passes any that it is not concerned with on to find_package.