CMake: Add an install_tools target for static builds

We offer a build target called 'host_tools' to build just host tools
and their dependencies within a Qt build, but it was not possible to
easily install the built tools.

Add convenience custom targets called 'install_tools' and
'install_tools_stripped' to install the host tools when building
a static Qt build.

The convenience targets will be useful for qdoc static builds, to
easily be able and install the tools, without having to specify each
tool's install target separately.

The current approach doesn't work for shared Qt builds because it
would necessitate tracking the libraries that the tools depend on, so
those are installed as well.

So for now, this is limited to static builds only, where there
are no shared library dependencies that have to be installed.

The implementation passes 'host_tools' as an installation component
for qt_internal_add_tool installed targets. The custom target then
just calls cmake --install with the component name.

Task-number: QTBUG-91243
Task-number: QTBUG-128730
Change-Id: Ic047ec3b8683043f496b4b2c3cf883a3e70440b3
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
(cherry picked from commit c64190caa7d515e0efc60a3c435d9d779efd5ac3)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Alexandru Croitor 2024-09-08 16:47:30 +02:00
parent ff0285ce6b
commit ef3db62459
2 changed files with 21 additions and 1 deletions

View File

@ -308,6 +308,24 @@ macro(qt_build_repo_begin)
if(NOT TARGET host_tools)
add_custom_target(host_tools)
add_custom_target(bootstrap_tools)
# TODO: Investigate complexity of installing tools for shared builds.
# Currently installing host tools without libraries only really makes sense for static
# builds. Tracking dependencies for shared builds is more involved.
if(NOT BUILD_SHARED_LIBS)
add_custom_target(install_tools
COMMAND ${CMAKE_COMMAND}
--install ${CMAKE_BINARY_DIR} --component host_tools
)
add_custom_target(install_tools_stripped
COMMAND ${CMAKE_COMMAND}
--install ${CMAKE_BINARY_DIR} --component host_tools --strip
)
if(NOT QT_INTERNAL_NO_INSTALL_TOOLS_BUILD_DEPS)
add_dependencies(install_tools host_tools)
add_dependencies(install_tools_stripped host_tools)
endif()
endif()
endif()
# Add benchmark meta target. It's collection of all benchmarks added/registered by

View File

@ -215,7 +215,9 @@ function(qt_internal_add_tool target_name)
qt_get_cmake_configurations(cmake_configs)
set(install_initial_call_args
EXPORT "${INSTALL_CMAKE_NAMESPACE}${arg_TOOLS_TARGET}ToolsTargets")
EXPORT "${INSTALL_CMAKE_NAMESPACE}${arg_TOOLS_TARGET}ToolsTargets"
COMPONENT host_tools
)
foreach(cmake_config ${cmake_configs})
qt_get_install_target_default_args(