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. Change-Id: Ic2a2d613dbf4fa7e7c51e9b73696bf14e4af866f Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit 2339cb3ea282d4ad31fd74fd2a127a986a29a3cf) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
5da0b7624f
commit
7857fad91e
@ -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