CMake: Fix forcing usage of host tools when doing a desktop build
One can now set QT_FORCE_FIND_TOOLS to ON together with passing a QT_HOST_PATH to ensure that a new desktop build uses already existing tools from a different Qt host (desktop) installation. Depends ona0e56294c1
to work, which is not in 6.2, but this change is still included in 6.2 because it cleans up the conditions a bit to make them more clear. Amends42d3b21c92
and5a779a4ad3
Pick-to: 6.2 Fixes: QTBUG-95099 Task-number: QTBUG-97658 Change-Id: If6258fb1091c6c1e457f22ae5f468b811bd20d57 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
parent
9ed274a48d
commit
c82bca9efe
@ -58,18 +58,32 @@ function(qt_internal_add_tool target_name)
|
||||
endif()
|
||||
|
||||
set(full_name "${QT_CMAKE_EXPORT_NAMESPACE}::${name}")
|
||||
set(imported_tool_target_found FALSE)
|
||||
set(imported_tool_target_already_found FALSE)
|
||||
|
||||
# This condition can only be TRUE if a previous find_package(Qt6${arg_TOOLS_TARGET}Tools)
|
||||
# was already done. That can happen if we are cross compiling or QT_FORCE_FIND_TOOLS was ON.
|
||||
# In such a case, we need to exit early if we're not going to also cross-build the tools.
|
||||
if(TARGET ${full_name})
|
||||
get_property(path TARGET ${full_name} PROPERTY LOCATION)
|
||||
message(STATUS "Tool '${full_name}' was found at ${path}.")
|
||||
set(imported_tool_target_found TRUE)
|
||||
if(CMAKE_CROSSCOMPILING AND NOT QT_BUILD_TOOLS_WHEN_CROSSCOMPILING)
|
||||
set(imported_tool_target_already_found TRUE)
|
||||
if(NOT QT_WILL_BUILD_TOOLS)
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(arg_TOOLS_TARGET AND (NOT QT_WILL_BUILD_TOOLS OR QT_BUILD_TOOLS_WHEN_CROSSCOMPILING)
|
||||
AND NOT imported_tool_target_found)
|
||||
# We need to search for the host Tools package when:
|
||||
# - doing a cross-build and tools are not cross-built
|
||||
# - doing a cross-build and tools ARE cross-built
|
||||
# - QT_FORCE_FIND_TOOLS is ON
|
||||
# This collapses to the condition below.
|
||||
# As an optimiziation, we don't search for the package one more time if the target
|
||||
# was already brought into scope from a previous find_package.
|
||||
set(search_for_host_package FALSE)
|
||||
if(NOT QT_WILL_BUILD_TOOLS OR QT_BUILD_TOOLS_WHEN_CROSSCOMPILING)
|
||||
set(search_for_host_package TRUE)
|
||||
endif()
|
||||
if(search_for_host_package AND NOT imported_tool_target_already_found)
|
||||
set(tools_package_name "Qt6${arg_TOOLS_TARGET}Tools")
|
||||
message(STATUS "Searching for tool '${full_name}' in package ${tools_package_name}.")
|
||||
|
||||
@ -286,8 +300,8 @@ function(qt_internal_add_tool target_name)
|
||||
endfunction()
|
||||
|
||||
function(qt_export_tools module_name)
|
||||
# Bail out when cross-compiling, unless QT_BUILD_TOOLS_WHEN_CROSSCOMPILING is on.
|
||||
if(CMAKE_CROSSCOMPILING AND NOT QT_BUILD_TOOLS_WHEN_CROSSCOMPILING)
|
||||
# Bail out when not building tools.
|
||||
if(NOT QT_WILL_BUILD_TOOLS)
|
||||
return()
|
||||
endif()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user