Controlling dependency source
Before or as part of addressing #22686, it would be useful to first allow the users to define dependency source globally and per project. I suggest the following:
- Add a
<Package>_PACKAGE_SOURCE
cache variable that contains one of:config
,module
,pkg-config
,fetch_content
,provider_<provider>
,unknown
. This variable is set by the correspondingfind_package
,FetchContent
, etc. commands - Alternatively or in addition, add a
package
level properties, where the package is defined whenever it enters:find_package(CONFIG)
,Find<Package>.cmake
,FetchContent_MakeAvailable
,<provider>_provide_dependency
. This would be similar toCMAKE_FIND_PACKAGE_NAME
, but more generalized- Would be nice to have all targets within a "package" scope populate some target property to point back to the package that populated it
- Add
CMAKE_FIND_PACKAGE_MODE
andCMAKE_FIND_<Package>_MODE
as control parameters to exclusively choose to use one mode. If no appropriate mode is defined, e.g.FethcContent_Declare
is not defined, then return<Package>_FOUND=False
. This will be an alternative/addition toCMAKE_REQUIRE_FIND_PACKAGE_<Package>
What do you guys think? What nuances am I missing here?
Edited by Cristian Le