From b1ad7f938e2f71288e65a8c9a86b732b89a6a345 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Thu, 11 Feb 2021 14:01:58 +0100 Subject: Generate information about user-facing applications in build dir When packaging different Qt versions for Linux distributions (or any distribution with a common bin dir), Qt tools cannot be installed to /usr/bin, because the executable names of the different Qt versions clash. To solve this conflict, our recommendation is to install Qt's tools to /usr/lib/qt6/bin and to create versioned symlinks to user-facing tools in /usr/bin. User-facing tools are tools that are supposed to be started manually by the user. They are marked in Qt's build system. Distro package maintainers can now configure with -DCMAKE_INSTALL_PREFIX=/usr -DINSTALL_BINDIR=/usr/lib/qt6/bin -DINSTALL_PUBLICBINDIR=/usr/bin and will find a file called user_facing_tool_links.txt in the build directory after the cmake run. Nothing will be installed to INSTALL_PUBLICBINDIR. Each line of user_facing_tool_links.txt consists of the installation path of a user-facing application followed by a space and the versioned link name in INSTALL_PUBLICBINDIR. Example content: /usr/lib/qt6/bin/qmake /usr/bin/qmake6 To actually create the versioned symlinks, the content of this file can be fed to ln like this: xargs ln -s < build-dir/user_facing_tool_links.txt Or the package maintainer may decide to do something completely different as suits their needs. This patch adds the USER_FACING argument to qt_internal_add_tool to mark tools as user-facing. In addition, every Qt created by qt_internal_add_app is treated as user-facing. The only tool this patch marks as user-facing in qtbase is qmake. Pick-to: 6.1 Fixes: QTBUG-89170 Change-Id: I52673b1c8d40f40f56a74203065553115e2c4de5 Reviewed-by: Kai Koehne Reviewed-by: Shawn Rutledge --- cmake/QtPostProcessHelpers.cmake | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'cmake/QtPostProcessHelpers.cmake') diff --git a/cmake/QtPostProcessHelpers.cmake b/cmake/QtPostProcessHelpers.cmake index 9a36e2ada4..89b112c2b0 100644 --- a/cmake/QtPostProcessHelpers.cmake +++ b/cmake/QtPostProcessHelpers.cmake @@ -707,3 +707,24 @@ function(qt_internal_install_prl_files) ) endforeach() endfunction() + +function(qt_internal_generate_user_facing_tools_info) + if("${INSTALL_PUBLICBINDIR}" STREQUAL "") + return() + endif() + get_property(user_facing_tool_targets GLOBAL PROPERTY QT_USER_FACING_TOOL_TARGETS) + set(lines "") + foreach(target ${user_facing_tool_targets}) + get_target_property(filename ${target} OUTPUT_NAME) + if(NOT filename) + set(filename ${target}) + endif() + qt_path_join(tool_target_path "${CMAKE_INSTALL_PREFIX}" "${INSTALL_BINDIR}" "${filename}") + qt_path_join(tool_link_path "${INSTALL_PUBLICBINDIR}" "${filename}${PROJECT_VERSION_MAJOR}") + list(APPEND lines "${tool_target_path} ${tool_link_path}") + endforeach() + string(REPLACE ";" "\n" content "${lines}") + string(APPEND content "\n") + set(out_file "${PROJECT_BINARY_DIR}/user_facing_tool_links.txt") + file(WRITE "${out_file}" "${content}") +endfunction() -- cgit v1.2.3