FetchContent_Declare() should record state of CMAKE_FIND_PACKAGE_TARGETS_GLOBAL
The CMAKE_FIND_PACKAGE_TARGETS_GLOBAL
variable can be used to specify the default behavior for whether find_package()
assumes the GLOBAL
keyword by default. Both the variable and the keyword are new in CMake 3.24, which is also the release that adds find_package()
/ FetchContent integration. When saving the declared details from the FetchContent_Declare()
call, we should add the GLOBAL
option to the find_package()
args saved with that call if CMAKE_FIND_PACKAGE_TARGETS_GLOBAL
is set to true.
If CMAKE_FIND_PACKAGE_TARGETS_GLOBAL
is unset or set to false when FetchContent_Declare()
is called, but it is set to true when FetchContent_MakeAvailable()
is called, this probably should also result in the GLOBAL
behavior being active. Basically, if CMAKE_FIND_PACKAGE_TARGETS_GLOBAL
is set to true when the content details are declared or used, then GLOBAL
will be the effective behavior. This should be clearly documented.