diff options
author | Robert Griebl <robert.griebl@qt.io> | 2023-08-12 02:16:07 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2023-09-01 16:58:13 +0000 |
commit | 9dcf923dad0e4fa3bfb1be7e3a3b4554528768e9 (patch) | |
tree | 38f821ff5ad4cc1fe599e873e35a614db1c3105d | |
parent | 1971204e91d41a365dcbebad9f1c7a67d716e6a3 (diff) |
cmake: allow compilation of appman-packager when cross-compiling
cmake will not compile tools when cross-compiling anyway, but due to
our custom check, you couldn't even force the build with
-DQT_FORCE_BUILD_TOOLS=ON if you needed to.
In addition, the documentation for the "tools-only" configure option
was very outdated.
Change-Id: Ib5e6a72414ba5bbe0c5dc98d8ec5d5e66790216e
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
(cherry picked from commit e5325d6f8bd4d3e78ce776623864f5c843dc3da3)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | doc/installation.qdoc | 4 | ||||
-rw-r--r-- | src/CMakeLists.txt | 6 | ||||
-rw-r--r-- | src/main-lib/Qt6AppManMainPrivateMacros.cmake | 31 | ||||
-rw-r--r-- | tests/data/CMakeLists.txt | 8 |
4 files changed, 37 insertions, 12 deletions
diff --git a/doc/installation.qdoc b/doc/installation.qdoc index 91369671..8eedee58 100644 --- a/doc/installation.qdoc +++ b/doc/installation.qdoc @@ -142,8 +142,8 @@ modules: peer-to-peer D-Bus. \row \li \c{tools-only} - \li Set to \c yes to only build tools: \l{Controller}{appman-controller} and - \l{Packager}{appman-packager}. + \li Set to \c yes to create a build that only compiles the tools (as in \e{Qt build tools}, that + are only built for the host Qt when cross compiling): \l{Packager}{appman-packager}. \row \li \c{widgets-support} \li Set to \c yes to enable support for Qt widgets. This option can be useful to enable the use diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ad23bb40..864a5a40 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -45,8 +45,6 @@ if(NOT QT_FEATURE_am_tools_only) endif() endif() -if(NOT QT_FEATURE_cross_compile OR QT_FEATURE_am_tools_only) - if (QT_FEATURE_am_installer) - add_subdirectory(tools/packager) - endif() +if (QT_FEATURE_am_installer) + add_subdirectory(tools/packager) endif() diff --git a/src/main-lib/Qt6AppManMainPrivateMacros.cmake b/src/main-lib/Qt6AppManMainPrivateMacros.cmake index 562113a4..55d77b27 100644 --- a/src/main-lib/Qt6AppManMainPrivateMacros.cmake +++ b/src/main-lib/Qt6AppManMainPrivateMacros.cmake @@ -1,5 +1,36 @@ set(_AM_MACROS_LOCATION ${CMAKE_CURRENT_LIST_DIR}) +function(qt_am_internal_find_host_packager) + if(TARGET ${QT_CMAKE_EXPORT_NAMESPACE}::appman-packager) + return() + endif() + if(NOT QT_HOST_PATH) + find_package(Qt6 COMPONENTS AppManMainPrivateTools) + return() + endif() + # Try to find the host version of the packager: + # Set up QT_HOST_PATH as an extra root path to look for the Tools package. + # If toolchain file already provides host paths in a predefined order, we shouldn't break it. + if(NOT "${QT_HOST_PATH_CMAKE_DIR}" IN_LIST CMAKE_PREFIX_PATH) + list(PREPEND CMAKE_PREFIX_PATH "${QT_HOST_PATH_CMAKE_DIR}") + endif() + if(NOT "${QT_HOST_PATH}" IN_LIST CMAKE_FIND_ROOT_PATH) + list(PREPEND CMAKE_FIND_ROOT_PATH "${QT_HOST_PATH}") + endif() + if(NOT "${QT_HOST_PATH}" IN_LIST CMAKE_PROGRAM_PATH) + list(PREPEND CMAKE_PROGRAM_PATH "${QT_HOST_PATH}") + endif() + # This can't use the find_package(Qt6 COMPONENTS) signature, because Qt6Config uses NO_DEFAULT + # and won't look at the prepend extra find root paths. + find_package(Qt6AppManMainPrivateTools ${PROJECT_VERSION} CONFIG + PATHS + ${_qt_additional_packages_prefix_path} + ${_qt_additional_packages_prefix_path_env} + ${QT_HOST_PATH_CMAKE_DIR} + NO_DEFAULT_PATH + ) +endfunction() + function(qt_am_internal_create_copy_command file) if (NOT ${CMAKE_CURRENT_BINARY_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}) add_custom_command(OUTPUT ${file} diff --git a/tests/data/CMakeLists.txt b/tests/data/CMakeLists.txt index 6f8be60c..521749b9 100644 --- a/tests/data/CMakeLists.txt +++ b/tests/data/CMakeLists.txt @@ -28,6 +28,8 @@ endforeach() qt_internal_collect_command_environment(env_path env_plugin_path) +qt_am_internal_find_host_packager() + if (WIN32) find_program(bash bash.exe PATHS ENV PATH @@ -44,18 +46,12 @@ if (WIN32) # /mingw64/bin to $PATH, which in most cases has incompatible versions of the stdc++ and # gcc libs, preventing the appman-packager from starting. - if (NOT TARGET ${QT_CMAKE_EXPORT_NAMESPACE}::appman-packager) - find_package(Qt6 COMPONENTS AppManMainPrivateTools) - endif() add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/packages COMMAND ${bash} -c 'export PATH="`cygpath -u -p \"${env_path}\"`:$$PATH" \; ${CMAKE_CURRENT_BINARY_DIR}/create-test-packages.sh $<TARGET_FILE:${QT_CMAKE_EXPORT_NAMESPACE}::appman-packager>' DEPENDS ${ALL_TEST_DATA_FILES} ) endif() else() - if (NOT TARGET ${QT_CMAKE_EXPORT_NAMESPACE}::appman-packager) - find_package(Qt6 COMPONENTS AppManMainPrivateTools) - endif() add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/packages COMMAND "${CMAKE_COMMAND}" -E env "PATH=${env_path}${QT_PATH_SEPARATOR}$ENV{PATH}" ${CMAKE_CURRENT_BINARY_DIR}/create-test-packages.sh $<TARGET_FILE:${QT_CMAKE_EXPORT_NAMESPACE}::appman-packager> |