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

Top-level project Config.cmake file aborts with FATAL_ERROR also when not required #537

Closed schuhschuh closed 8 years ago

schuhschuh commented 8 years ago

The default <PKG>Config.cmake file generated by BASIS for a top-level project with project modules as components aborts with a FATAL_ERROR when a module is requested that was not built as part of the package. But when the package components are not required (i.e., optional dependency), the configuration should not be aborted and simply the components be missing from the output include directories and link libraries lists.

schuhschuh commented 8 years ago

The CMake documentation now details how Find modules should behave for discovering required and optional components. Maybe this gives some guidelines on how to do so in the package Config file. For example, set the <Pkg>_<Module>_FOUND variable for required and especially optional components. Do not raise a FATAL_ERROR when all required components are found. The <Pkg>_FOUND variable will then be set by CMake's find_package to TRUE as well as <Pkg>_DIR to the location of the <Pkg>Config.cmake file of the top-level project.

schuhschuh commented 8 years ago

The issue is addressed by this commit to the CMake BASIS Modules develop branch.

schuhschuh commented 8 years ago
schuhschuh commented 8 years ago

The <Pkg>_FIND_REQUIRED_<Component> variable is always set by CMake when the COMPONENTS or OPTIONAL_COMPONENTS options are used. Depending on which of these, the value is either 1 (true) or 0 (false). The <Pkg>_FIND_REQUIRED variable is only set when the REQUIRED option is given.