diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2021-10-20 16:37:33 +0200 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2021-10-29 15:34:12 +0200 |
commit | c82bca9efe79a4913499d08d2bc814cb32cfcef9 (patch) | |
tree | 1461fb156bf191a728a22cda857563d380611c2d /cmake | |
parent | 9ed274a48dc45ec05a834fa02c54dff09613934e (diff) |
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 on a0e56294c1e80f34147c5a992b314776e1b6c757
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.
Amends 42d3b21c92525ea6a430c67e577a5991d679fa1d
and 5a779a4ad350accadc4337d332eedb29ba1cc26b
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>
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/QtToolHelpers.cmake | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/cmake/QtToolHelpers.cmake b/cmake/QtToolHelpers.cmake index 515063243b..86621f4871 100644 --- a/cmake/QtToolHelpers.cmake +++ b/cmake/QtToolHelpers.cmake @@ -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() |