CMake: Add switch for allowing missing Qt6*Tools packages

Consider a cross build of Qt with qtbase, qtshadertools and
qtdeclarative. If a user projects only links against QtQml without
creating an actual QtQuick module, no host tools from qtdeclarative are
needed.

Normally, find_package(Qt6Qml) pulls in Qt6QmlTools and errors out if
it's not found. By setting QT_ALLOW_MISSING_TOOLS_PACKAGES when
configuring Qt, one can disable the error and build a user project such
as the one outlined above.

Fixes: QTBUG-109547
Change-Id: I45e727713912d19e6007a7fbf3d61533f82b71d9
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Jaeyoon Jung <jaeyoon.jung@lge.com>
(cherry picked from commit 94e474b48e9d3c6434339afe166c2329f8c36ea2)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Joerg Bornemann 2023-01-06 16:12:34 +01:00 committed by Qt Cherry-pick Bot
parent 0cd48a0bc8
commit b41b27352d
2 changed files with 6 additions and 1 deletions

View File

@ -669,6 +669,11 @@ set(QT_VISIBILITY_AVAILABLE TRUE)")
set(QT_LIBINFIX \"${QT_LIBINFIX}\")")
endif()
# Store whether find_package(Qt6Foo) should succeed if Qt6FooTools is missing.
if(QT_ALLOW_MISSING_TOOLS_PACKAGES)
string(APPEND qtcore_extra_cmake_code "
set(QT_ALLOW_MISSING_TOOLS_PACKAGES TRUE)")
endif()
endif()
configure_file("${CMAKE_CURRENT_LIST_DIR}/${INSTALL_CMAKE_NAMESPACE}${target}ConfigExtras.cmake.in"

View File

@ -67,7 +67,7 @@ macro(_qt_internal_find_tool_dependencies target target_dep_list)
"${_qt_cmake_dir}"
${_qt_additional_packages_prefix_paths}
)
if (NOT ${__qt_${target}_pkg}_FOUND)
if (NOT ${__qt_${target}_pkg}_FOUND AND NOT QT_ALLOW_MISSING_TOOLS_PACKAGES)
set(${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)
set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE
"${CMAKE_FIND_PACKAGE_NAME} could not be found because dependency \