Avoid creating Plugin targets if the dependencies are missing
The plugin lookup mechanism doesn't handle the situation, when the plugin is available but it's private dependency(static plugin case) is missing. In this case we currently silently bypass the dependency lookup and create targets. So users see the confusing message about missing linked target, like: Qt6QSQLiteDriverPluginTargets.cmake:61 (set_target_properties): The link interface of target "Qt6::QSQLiteDriverPlugin" contains: SQLite::SQLite3 but the target was not found. Possible reasons include: * There is a typo in the target name. * A find_package call is missing for an IMPORTED target. * An ALIAS target is missing. This indeed should be handled properly and we should omit creating targets especially if users don't really use the plugin directly. Also if dependencies are not satisfied it looks logically to set the <plugin>_FOUND to false as this will be yet another indicator for user that the plugin is not found. Task-number: QTBUG-132244 Pick-to: 6.8 6.9 6.5 Change-Id: I8685163df0dee3a728c724901f69780569ffcad5 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
parent
c08a92307d
commit
8d0283ad2c
@ -26,8 +26,12 @@ if (NOT QT_NO_CREATE_TARGETS)
|
||||
# Find required dependencies, if any.
|
||||
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@Dependencies.cmake")
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@Dependencies.cmake")
|
||||
else()
|
||||
set(@target@_FOUND TRUE)
|
||||
endif()
|
||||
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@Targets.cmake")
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@AdditionalTargetInfo.cmake")
|
||||
if(@target@_FOUND)
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@Targets.cmake")
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@AdditionalTargetInfo.cmake")
|
||||
endif()
|
||||
endif()
|
||||
|
@ -18,4 +18,8 @@ set(__qt_@target@_find_dependency_paths "@find_dependency_paths@")
|
||||
_qt_internal_find_qt_dependencies("@target@" __qt_@target@_target_deps
|
||||
__qt_@target@_find_dependency_paths)
|
||||
|
||||
set(@target@_FOUND TRUE)
|
||||
if(__qt_${target}_missing_deps)
|
||||
set(@target@_FOUND FALSE)
|
||||
else()
|
||||
set(@target@_FOUND TRUE)
|
||||
endif()
|
||||
|
@ -34,6 +34,9 @@ macro(_qt_internal_find_third_party_dependencies target target_dep_list)
|
||||
find_package(${__qt_${target}_find_package_args})
|
||||
else()
|
||||
find_dependency(${__qt_${target}_find_package_args})
|
||||
if(NOT ${__qt_${target}_pkg}_FOUND)
|
||||
list(APPEND __qt_${target}_missing_deps "${__qt_${target}_pkg}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
_qt_internal_get_package_components_id(
|
||||
@ -129,7 +132,6 @@ macro(_qt_internal_find_qt_dependencies target target_dep_list find_dependency_p
|
||||
list(GET __qt_${target}_target_dep 1 __qt_${target}_version)
|
||||
|
||||
if (NOT ${__qt_${target}_pkg}_FOUND)
|
||||
|
||||
# TODO: Remove Private handling once sufficient time has passed, aka all developers
|
||||
# updated their builds not to contain stale FooDependencies.cmake files without the
|
||||
# _qt_package_name property.
|
||||
@ -149,6 +151,9 @@ macro(_qt_internal_find_qt_dependencies target target_dep_list find_dependency_p
|
||||
${_qt_additional_packages_prefix_paths}
|
||||
${__qt_use_no_default_path_for_qt_packages}
|
||||
)
|
||||
if(NOT ${__qt_${target}_pkg}_FOUND)
|
||||
list(APPEND __qt_${target}_missing_deps "${__qt_${target}_pkg}")
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
Loading…
x
Reference in New Issue
Block a user