find_package_default_component_list

include (OrangesFindPackageHelpers)

View the full docs for this module.

find_package_default_component_list (<validComponents...>)

Pass the list of valid component names to this macro, and it detects if the user requested any invalid components in their find_package() call, and raises a warning (if the QUIET flag wasn’t passed to find_package()).

Additionally, if All, ALL, or all was passed as a component name by the user to find_package(), then this macro sets the variable ${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS to the full list of valid component names passed to this macro. If the All component was specified as a required component in the user’s find_package() call, then this macro sets the variables ${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED_<comp> to ON for each of the valid component names.

For example, if you have a module FindFoo.cmake that uses this macro like so:

find_package_default_component_list (Comp1 Comp2)

Then if a user calls:

find_package (Foo COMPONENTS ALL)

Then inside the FindFoo.cmake module:

# After this call...
find_package_default_component_list (Comp1 Comp2)

# This will print out "Components: Comp1;Comp2"
message (STATUS "Components: ${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS")

Similarly, if the user calls:

find_package (Foo COMPONENTS blargh)

Then the call to find_package_default_component_list in the FindFoo.cmake module will print a warning that blargh is not a valid component name.