A well behaved library using Qt6 and creating cmake config file packages might have an effect like this:
# Make my life and my users life easier by making Qt version use unambiguous.
# We have to use an ugly variable to save the existing state:
# Unset this so that it doesn't leak
add_library(Grantlee6::Templates SHARED IMPORTED)
set_property(TARGET Grantlee6::Templates PROPERTY
Now, when someone tries to use my library and tries to use versionless targets, it does not work:
# Finds Qt6Core and defines versioned Qt6::Core but does not define versionless Qt::Core
# Has no effect because it has already been found (does not create versionless Qt::Core):
However reordering makes it do what the user expected in this case:
# Finds Qt6Core and defines versioned Qt6::Core and versionless Qt::Core
# The internal find_package(Qt6Core) has no effect because it is already found:
This is bad. The workingness or not of find_package() calls should not be order dependent. This gets even worse when using multiple libraries which use Qt:
# Contains find_package(Qt6Core) but prevents versionless targets:
# The find_package(Qt6Core) in BarConfig.cmake has no effect, but Bar::Core uses versionless Qt::Core in its INTERFACE_LINK_LIBRARIES.
# This will lead to failure at generate time.
In the above case, the user needs to put an additional find_package(Qt6Core) before those two find_package calls.
# Only needed to solve dialect problem in the Qt cmake files:
These versionless targets mean that there are now two dialects of Qt in the buildsystem.
They are incompatible and that will create problems.
The decision to introduce them should be reversed.