CMake: also allow building tools when found elsewhere in host builds
Previously, this was only supported when cross-compiling, but that's an unnecessary limitation. Instead, make it possible to build the "host" tools (notably qmake) even when they've been found elsewhere due to QT_FORCE_FIND_TOOLS=ON and a supplied QT_HOST_PATH. The combination of QT_FORCE_FIND_TOOLS and QT_FORCE_BUILD_TOOLS set to ON is useful for developers who touch content that ends up in the bootstrap library. QT_BUILD_TOOLS_WHEN_CROSSCOMPILING is deprecated in favor of QT_FORCE_BUILD_TOOLS. [ChangeLog][CMake] QT_BUILD_TOOLS_WHEN_CROSSCOMPILING has been deprecated in favor of QT_FORCE_BUILD_TOOLS. The latter can be used in combination with QT_FORCE_FIND_TOOLS and QT_HOST_PATH to use tools from a host Qt even for a non-cross build and still build the tools. Fixes: QTBUG-99683 Change-Id: I0e5f6bec596a4a78bd3bfffd16c8fb486181f9b6 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
634717135d
commit
acfbe3b779
@ -592,9 +592,14 @@ endif()\n")
|
||||
"set(QT_UIKIT_SDK \"${QT_UIKIT_SDK}\" CACHE BOOL \"\")\n")
|
||||
endif()
|
||||
|
||||
if(CMAKE_CROSSCOMPILING AND QT_BUILD_TOOLS_WHEN_CROSSCOMPILING)
|
||||
if(QT_FORCE_FIND_TOOLS)
|
||||
string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS
|
||||
"set(QT_BUILD_TOOLS_WHEN_CROSSCOMPILING \"TRUE\" CACHE BOOL \"\" FORCE)\n")
|
||||
"set(QT_FORCE_FIND_TOOLS \"TRUE\" CACHE BOOL \"\" FORCE)\n")
|
||||
endif()
|
||||
|
||||
if(QT_FORCE_BUILD_TOOLS)
|
||||
string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS
|
||||
"set(QT_FORCE_BUILD_TOOLS \"TRUE\" CACHE BOOL \"\" FORCE)\n")
|
||||
endif()
|
||||
|
||||
if(QT_INTERNAL_EXAMPLES_INSTALL_PREFIX)
|
||||
|
@ -837,7 +837,7 @@ function(qt_get_build_parts out_var)
|
||||
list(APPEND parts "tests")
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_CROSSCOMPILING OR QT_BUILD_TOOLS_WHEN_CROSSCOMPILING)
|
||||
if(NOT CMAKE_CROSSCOMPILING OR QT_FORCE_BUILD_TOOLS)
|
||||
list(APPEND parts "tools")
|
||||
endif()
|
||||
|
||||
|
@ -85,7 +85,7 @@ function(qt_generate_qmake_and_qtpaths_wrapper_for_target)
|
||||
|
||||
# Call the configuration file something else but qt.conf to avoid
|
||||
# being picked up by the qmake executable that's created if
|
||||
# QT_BUILD_TOOLS_WHEN_CROSSCOMPILING is enabled.
|
||||
# QT_FORCE_BUILD_TOOLS is enabled.
|
||||
qt_path_join(qt_conf_path "${INSTALL_BINDIR}" "target_qt.conf")
|
||||
|
||||
set(prefix "${CMAKE_INSTALL_PREFIX}")
|
||||
@ -146,7 +146,7 @@ HostSpec=${QT_QMAKE_HOST_MKSPEC}
|
||||
endif()
|
||||
|
||||
set(wrapper_prefix)
|
||||
if(QT_BUILD_TOOLS_WHEN_CROSSCOMPILING)
|
||||
if(QT_FORCE_BUILD_TOOLS)
|
||||
# Avoid collisions with the cross-compiled qmake/qtpaths binaries.
|
||||
set(wrapper_prefix "host-")
|
||||
endif()
|
||||
|
@ -216,7 +216,7 @@ set(BUILD_TESTING ${QT_BUILD_TESTS} CACHE INTERNAL "")
|
||||
# Like in qttools/assistant/assistant.pro, load(qt_app), which is guarded by a qtNomakeTools() call.
|
||||
|
||||
set(_qt_build_tools_by_default_default ON)
|
||||
if(CMAKE_CROSSCOMPILING AND NOT QT_BUILD_TOOLS_WHEN_CROSSCOMPILING)
|
||||
if(CMAKE_CROSSCOMPILING AND NOT QT_FORCE_BUILD_TOOLS)
|
||||
set(_qt_build_tools_by_default_default OFF)
|
||||
endif()
|
||||
option(QT_BUILD_TOOLS_BY_DEFAULT "Should tools be built as part of the default 'all' target."
|
||||
|
@ -52,7 +52,7 @@ function(qt_internal_add_tool target_name)
|
||||
" (QT_WILL_BUILD_TOOLS is ${QT_WILL_BUILD_TOOLS}).")
|
||||
endif()
|
||||
|
||||
if(CMAKE_CROSSCOMPILING AND QT_BUILD_TOOLS_WHEN_CROSSCOMPILING AND (name STREQUAL target_name))
|
||||
if(QT_WILL_RENAME_TOOL_TARGETS AND (name STREQUAL target_name))
|
||||
message(FATAL_ERROR
|
||||
"qt_internal_add_tool must be passed a target obtained from qt_get_tool_target_name.")
|
||||
endif()
|
||||
@ -61,8 +61,8 @@ function(qt_internal_add_tool target_name)
|
||||
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.
|
||||
# was already done. That can happen if QT_FORCE_FIND_TOOLS was ON or we're cross-compiling.
|
||||
# In such a case, we need to exit early if we're not going to also build the tools.
|
||||
if(TARGET ${full_name})
|
||||
get_property(path TARGET ${full_name} PROPERTY LOCATION)
|
||||
message(STATUS "Tool '${full_name}' was found at ${path}.")
|
||||
@ -72,15 +72,12 @@ function(qt_internal_add_tool target_name)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# 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.
|
||||
# We need to search for the host Tools package when doing a cross-build
|
||||
# or when QT_FORCE_FIND_TOOLS is ON.
|
||||
# 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)
|
||||
if(NOT QT_WILL_BUILD_TOOLS OR QT_WILL_RENAME_TOOL_TARGETS)
|
||||
set(search_for_host_package TRUE)
|
||||
endif()
|
||||
if(search_for_host_package AND NOT imported_tool_target_already_found)
|
||||
@ -160,7 +157,7 @@ function(qt_internal_add_tool target_name)
|
||||
qt_internal_append_known_modules_with_tools("${arg_TOOLS_TARGET}")
|
||||
get_property(path TARGET ${full_name} PROPERTY LOCATION)
|
||||
message(STATUS "${full_name} was found at ${path} using package ${tools_package_name}.")
|
||||
if (NOT QT_BUILD_TOOLS_WHEN_CROSSCOMPILING)
|
||||
if (NOT QT_FORCE_BUILD_TOOLS)
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
@ -171,11 +168,7 @@ function(qt_internal_add_tool target_name)
|
||||
"${tools_package_name} package. "
|
||||
"Package found: ${${tools_package_name}_FOUND}")
|
||||
else()
|
||||
if(QT_BUILD_TOOLS_WHEN_CROSSCOMPILING)
|
||||
message(STATUS "Tool '${target_name}' will be cross-built from source.")
|
||||
else()
|
||||
message(STATUS "Tool '${full_name}' will be built from source.")
|
||||
endif()
|
||||
message(STATUS "Tool '${full_name}' will be built from source.")
|
||||
endif()
|
||||
|
||||
set(disable_autogen_tools "${arg_DISABLE_AUTOGEN_TOOLS}")
|
||||
@ -366,7 +359,7 @@ function(qt_export_tools module_name)
|
||||
list(APPEND extra_cmake_includes "${_extra_cmake_includes}")
|
||||
endif()
|
||||
|
||||
if (CMAKE_CROSSCOMPILING AND QT_BUILD_TOOLS_WHEN_CROSSCOMPILING)
|
||||
if (QT_WILL_RENAME_TOOL_TARGETS)
|
||||
string(REGEX REPLACE "_native$" "" tool_name ${tool_name})
|
||||
endif()
|
||||
set(extra_cmake_statements "${extra_cmake_statements}
|
||||
@ -471,7 +464,7 @@ endfunction()
|
||||
# If the user specifies to build tools when cross-compiling, then the
|
||||
# suffix "_native" is appended.
|
||||
function(qt_get_tool_target_name out_var name)
|
||||
if (CMAKE_CROSSCOMPILING AND QT_BUILD_TOOLS_WHEN_CROSSCOMPILING)
|
||||
if (QT_WILL_RENAME_TOOL_TARGETS)
|
||||
set(${out_var} ${name}_native PARENT_SCOPE)
|
||||
else()
|
||||
set(${out_var} ${name} PARENT_SCOPE)
|
||||
@ -482,20 +475,44 @@ endfunction()
|
||||
# This is the inverse of qt_get_tool_target_name.
|
||||
function(qt_tool_target_to_name out_var target)
|
||||
set(name ${target})
|
||||
if (CMAKE_CROSSCOMPILING AND QT_BUILD_TOOLS_WHEN_CROSSCOMPILING)
|
||||
if (QT_WILL_RENAME_TOOL_TARGETS)
|
||||
string(REGEX REPLACE "_native$" "" name ${target})
|
||||
endif()
|
||||
set(${out_var} ${name} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# Sets QT_WILL_BUILD_TOOLS if tools will be built.
|
||||
# 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)
|
||||
if(QT_FORCE_FIND_TOOLS OR (CMAKE_CROSSCOMPILING AND NOT QT_BUILD_TOOLS_WHEN_CROSSCOMPILING))
|
||||
if(CMAKE_CROSSCOMPILING AND QT_BUILD_TOOLS_WHEN_CROSSCOMPILING)
|
||||
# pre-6.4 compatibility flag (remove sometime in the future)
|
||||
message(WARNING "QT_BUILD_TOOLS_WHEN_CROSSCOMPILING is deprecated. "
|
||||
"Please use QT_FORCE_BUILD_TOOLS instead.")
|
||||
set(QT_FORCE_BUILD_TOOLS TRUE CACHE INTERNAL "" FORCE)
|
||||
endif()
|
||||
|
||||
# By default, we build our own tools unless we're cross-building.
|
||||
set(need_target_rename 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()
|
||||
else()
|
||||
set(will_build_tools TRUE)
|
||||
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()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
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)
|
||||
endfunction()
|
||||
|
||||
# Use this macro to exit a file or function scope unless we're building tools. This is supposed to
|
||||
|
Loading…
x
Reference in New Issue
Block a user