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 <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Alexey Edelev 2024-02-08 13:57:04 +01:00
parent 4c58e16882
commit 0b79ee6d3b

View File

@ -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)