CMake: Warn when qt_find_package is used with Qt target names
qt_find_package is only meant to be used for looking up 3rd party packages. Using it with Qt packages can cause issues where we record the Qt packages as 3rd party packages. When using a developer build, issue a warning when qt_find_package is called with a provided target that starts with the Qt6:: namespace. Pick-to: 6.8 Change-Id: Ic2a2d613dbf4fa7e7c51e9b73696bf14e4af866f Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
parent
d2e85cede0
commit
2339cb3ea2
@ -167,6 +167,19 @@ macro(qt_find_package)
|
||||
set(qt_find_package_target_name ${aliased_target})
|
||||
endif()
|
||||
|
||||
if("${qt_find_package_target_name}" MATCHES "${QT_CMAKE_EXPORT_NAMESPACE}::"
|
||||
AND QT_FEATURE_developer_build
|
||||
)
|
||||
message(AUTHOR_WARNING
|
||||
"qt_find_package() should NOT be used to look up Qt packages. "
|
||||
"It should only be used to look up 3rd party packages. "
|
||||
"Please remove the "
|
||||
"qt_find_package(${ARGV0} PROVIDED_TARGETS "
|
||||
"${qt_find_package_target_name}) call and contact the build tools team "
|
||||
"in case the removal is causing issues."
|
||||
)
|
||||
endif()
|
||||
|
||||
set_target_properties(${qt_find_package_target_name} PROPERTIES
|
||||
INTERFACE_QT_PACKAGE_NAME ${ARGV0}
|
||||
INTERFACE_QT_PACKAGE_IS_OPTIONAL ${arg_MARK_OPTIONAL})
|
||||
|
Loading…
x
Reference in New Issue
Block a user