FetchContent: Multiple canonical names
My understanding is that if there are multiple canonical names used in the FetchContent hierarchy, there would multiple instances of the project populated, e.g.
FetchContent_Declare(My_Name_A
GIT_REPOSITORY https://github.com/org/mynameA
GIT_TAG main
FIND_PACKAGE_ARGS NAMES My_Name_A MyNameA
)
...
FetchContent_Declare(MyNameA
GIT_REPOSITORY https://github.com/org/mynameA
GIT_TAG v0.1.0
OVERRIDE_FIND_PACKAGE
)
A more practical example would be googletest
vs gtest
as the canonical names. But in this case the intention is to have them unified as shown through the usage of FIND_PACKAGE_ARGS
. Is there a temporary workaround or a permanent solution to this?
My thinking is that if FIND_PACKAGE_ARGS
or OVERRIDE_FIND_PACKAGE
then we know that there is a common canonical name either in the content_name
or in the variables NAMES
. Then a property can be set across all _FetchContent_${contentNameLower}_canonical_names
recursively so that each package is made aware of the canonical name of the others and then the appropriate top-level option can be chosen (maybe having another property _FetchContent_${contentNameLower}_redirect
internally
This is also related to #25322.