Skip to content

Commit

Permalink
CMake: Add an install_tools target for static builds
Browse files Browse the repository at this point in the history
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 c64190c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
  • Loading branch information
alcroito committed Nov 2, 2024
1 parent ff0285c commit ef3db62
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
18 changes: 18 additions & 0 deletions cmake/QtBuildRepoHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion cmake/QtToolHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit ef3db62

Please sign in to comment.