From 0b79ee6d3bb569767d8be42d64783c286ac82293 Mon Sep 17 00:00:00 2001 From: Alexey Edelev Date: Thu, 8 Feb 2024 13:57:04 +0100 Subject: [PATCH] Make possible partial tool lookup when using QT_HOST_PATH Consider QT_HOST_PATH when setting the QT_WILL_BUILD_TOOLS flag. In this case if we do not crosscompile or require building tools aka QT_FORCE_BUILD_TOOLS=ON, we may by pass tool_FOUND check and assume that we will try building the missing tool. Set qt_require_find_tools GLOBAL property to indicate the tools lookup requirement. For tools that can be found we will try re-using them from QT_HOST_PATH, but not building from scratch. Change-Id: I94e92f62eb799308e38721b4d580052bb4bb35f9 Reviewed-by: Qt CI Bot Reviewed-by: Alexandru Croitor --- cmake/QtToolHelpers.cmake | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/cmake/QtToolHelpers.cmake b/cmake/QtToolHelpers.cmake index 9fa84146b84..95749451aee 100644 --- a/cmake/QtToolHelpers.cmake +++ b/cmake/QtToolHelpers.cmake @@ -497,25 +497,34 @@ endfunction() # Sets QT_WILL_BUILD_TOOLS if tools will be built and QT_WILL_RENAME_TOOL_TARGETS # if those tools have replaced naming. function(qt_check_if_tools_will_be_built) - # By default, we build our own tools unless we're cross-building. + # By default, we build our own tools unless we're cross-building or QT_HOST_PATH is set. set(need_target_rename FALSE) + set(require_find_tools FALSE) if(CMAKE_CROSSCOMPILING) set(will_build_tools FALSE) if(QT_FORCE_BUILD_TOOLS) set(will_build_tools TRUE) set(need_target_rename TRUE) endif() + set(require_find_tools TRUE) else() - set(will_build_tools TRUE) + if(QT_HOST_PATH) + set(will_build_tools FALSE) + else() + set(will_build_tools TRUE) + endif() if(QT_FORCE_FIND_TOOLS) set(will_build_tools FALSE) - if(QT_FORCE_BUILD_TOOLS) - set(will_build_tools TRUE) - set(need_target_rename TRUE) - endif() + set(require_find_tools TRUE) + endif() + if(QT_FORCE_BUILD_TOOLS) + set(will_build_tools TRUE) + set(need_target_rename TRUE) endif() endif() + set_property(GLOBAL PROPERTY qt_require_find_tools "${require_find_tools}") + set(QT_WILL_BUILD_TOOLS ${will_build_tools} CACHE INTERNAL "Are tools going to be built" FORCE) set(QT_WILL_RENAME_TOOL_TARGETS ${need_target_rename} CACHE INTERNAL "Do tool targets need to be renamed" FORCE) @@ -667,7 +676,8 @@ function(qt_internal_find_tool out_var target_name tools_target) endif() endif() - if(NOT QT_WILL_BUILD_TOOLS) + get_property(require_find_tools GLOBAL PROPERTY qt_require_find_tools) + if(require_find_tools AND NOT TARGET ${full_name}) if(${${tools_package_name}_FOUND}) set(pkg_found_msg "") string(APPEND pkg_found_msg @@ -684,7 +694,9 @@ function(qt_internal_find_tool out_var target_name tools_target) message(FATAL_ERROR "Failed to find the host tool \"${full_name}\". It is part of " ${pkg_found_msg}) - else() + endif() + + if(QT_WILL_BUILD_TOOLS) message(STATUS "Tool '${full_name}' will be built from source.") endif() set(${out_var} "TRUE" PARENT_SCOPE)