Closed schuhschuh closed 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.
The issue is addressed by this commit to the CMake BASIS Modules develop branch.
<Pkg>_FIND_REQUIRED_<Component>
is set by find_package
. Which combination of REQUIRED
, COMPONENTS
, and OPTIONAL_COMPONENTS
result in which settings? Possibly adjust the Config.cmake.in
if necessary.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.
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.