diff options
author | Robert Griebl <robert.griebl@qt.io> | 2022-07-29 16:29:05 +0200 |
---|---|---|
committer | Robert Griebl <robert.griebl@qt.io> | 2022-09-26 18:16:39 +0200 |
commit | 2f8b01d77408a356dfc4c38a4012b97df56a1ca6 (patch) | |
tree | 721f3b64db64f21adfc0067c4b78e241687bdc41 | |
parent | a8f6f09df5f580b0b201267cac73d99c2f9ed348 (diff) | |
download | qtapplicationmanager-2f8b01d77408a356dfc4c38a4012b97df56a1ca6.tar.gz |
CMake: our tools are really apps as far as the build system is concerned
The tool syntax got ported over from the old qmake system, but this
leads to problems nowadays on cross or multi-config builds, where the
tools are not built at all, unless they are built explicitly.
What we call tools, really are apps for Qt's cmake build system, so
all of those (except the packager and uploader (*), which really are build-
time tools) have been converted to be built as apps.
(*) the uploader should be retired or moved to the
qt-apps/qtauto-deployment-server repository anyway.
Change-Id: I7be0ce63625e53d0bc65387c5e5200c71c00b48a
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Dominik Holland <dominik.holland@qt.io>
-rw-r--r-- | src/CMakeLists.txt | 19 | ||||
-rw-r--r-- | src/main-lib/main.cpp | 1 | ||||
-rw-r--r-- | src/tools/appman/CMakeLists.txt | 11 | ||||
-rw-r--r-- | src/tools/controller/CMakeLists.txt | 21 | ||||
-rw-r--r-- | src/tools/dumpqmltypes/CMakeLists.txt | 50 | ||||
-rw-r--r-- | src/tools/launcher-qml/CMakeLists.txt | 4 | ||||
-rw-r--r-- | src/tools/testrunner/CMakeLists.txt | 10 | ||||
-rw-r--r-- | tests/data/CMakeLists.txt | 2 |
8 files changed, 50 insertions, 68 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0e5ef741..a850f505 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -32,15 +32,16 @@ if(NOT QT_FEATURE_am_tools_only) if(TARGET Qt::DBus) add_subdirectory(launcher-lib) - endif() + add_subdirectory(tools/controller) - # This tool links against everything to extract the Qml type information - if (QT_FEATURE_am_installer AND TARGET Qt::DBus) - add_subdirectory(tools/dumpqmltypes) - endif() + # This tool links against everything to extract the Qml type information + if (QT_FEATURE_am_installer) + add_subdirectory(tools/dumpqmltypes) + endif() - if (TARGET Qt::DBus AND QT_FEATURE_am_multi_process) - add_subdirectory(tools/launcher-qml) + if (QT_FEATURE_am_multi_process) + add_subdirectory(tools/launcher-qml) + endif() endif() endif() @@ -51,7 +52,3 @@ if(NOT QT_FEATURE_cross_compile OR QT_FEATURE_am_tools_only) add_subdirectory(tools/uploader) endif() - -if(TARGET Qt::DBus) - add_subdirectory(tools/controller) -endif() diff --git a/src/main-lib/main.cpp b/src/main-lib/main.cpp index a31a3b71..86468bf3 100644 --- a/src/main-lib/main.cpp +++ b/src/main-lib/main.cpp @@ -991,6 +991,7 @@ void Main::setupDBus(const std::function<QString(const char *)> &busForInterface #else Q_UNUSED(busForInterface) Q_UNUSED(policyForInterface) + Q_UNUSED(instanceId) #endif // defined(QT_DBUS_LIB) && !defined(AM_DISABLE_EXTERNAL_DBUS_INTERFACES) } diff --git a/src/tools/appman/CMakeLists.txt b/src/tools/appman/CMakeLists.txt index 3ccd6b76..e52ae26d 100644 --- a/src/tools/appman/CMakeLists.txt +++ b/src/tools/appman/CMakeLists.txt @@ -1,9 +1,6 @@ -qt_get_tool_target_name(target_name appman) -qt_internal_add_tool(${target_name} - USER_FACING +qt_internal_add_app(appman EXCEPTIONS - TOOLS_TARGET AppManMainPrivate SOURCES appman.cpp LIBRARIES @@ -12,8 +9,6 @@ qt_internal_add_tool(${target_name} AM_COMPILING_APPMAN ) -if (TARGET ${target_name}) - include(QtAppManBuildConfig) +include(QtAppManBuildConfig) - qtam_internal_add_build_config(${target_name}) -endif() +qtam_internal_add_build_config(appman) diff --git a/src/tools/controller/CMakeLists.txt b/src/tools/controller/CMakeLists.txt index d147f8af..7a0dbfa2 100644 --- a/src/tools/controller/CMakeLists.txt +++ b/src/tools/controller/CMakeLists.txt @@ -1,9 +1,6 @@ -qt_get_tool_target_name(target_name appman-controller) -qt_internal_add_tool(${target_name} - USER_FACING +qt_internal_add_app(appman-controller EXCEPTIONS - TOOLS_TARGET AppManMainPrivate SOURCES controller.cpp interrupthandler.cpp interrupthandler.h @@ -15,15 +12,13 @@ qt_internal_add_tool(${target_name} AM_COMPILING_APPMAN ) -if (TARGET ${target_name}) - qt_internal_extend_target(${target_name} - DBUS_INTERFACE_SOURCES +qt_internal_extend_target(appman-controller + DBUS_INTERFACE_SOURCES ../../dbus-lib/io.qt.packagemanager.xml - ) - qt_internal_extend_target(${target_name} - DBUS_INTERFACE_SOURCES +) +qt_internal_extend_target(appman-controller + DBUS_INTERFACE_SOURCES ../../dbus-lib/io.qt.applicationmanager.xml - DBUS_INTERFACE_FLAGS + DBUS_INTERFACE_FLAGS -i dbus-utilities.h - ) -endif() +) diff --git a/src/tools/dumpqmltypes/CMakeLists.txt b/src/tools/dumpqmltypes/CMakeLists.txt index bd1a9d4e..3739768e 100644 --- a/src/tools/dumpqmltypes/CMakeLists.txt +++ b/src/tools/dumpqmltypes/CMakeLists.txt @@ -1,8 +1,6 @@ -qt_get_tool_target_name(target_name appman-dumpqmltypes) -qt_internal_add_tool(${target_name} +qt_internal_add_app(appman-dumpqmltypes EXCEPTIONS - TOOLS_TARGET AppManMainPrivate SOURCES dumpqmltypes.cpp LIBRARIES @@ -21,6 +19,26 @@ qt_internal_add_tool(${target_name} AM_COMPILING_APPMAN ) +# regenerate the qmltypes, if possible +if(NOT QT_FEATURE_cross_compile) + qt_internal_collect_command_environment(env_path env_plugin_path) + + # We have to set the env to get the PATH set to find the Qt libraries + # needed by the appman-dumpqmltypes binary (we cannot guarantee that the + # target is in $QTDIR/bin) + + add_custom_command( + TARGET appman-dumpqmltypes + POST_BUILD + BYPRODUCTS "qmltypes" + COMMAND "${CMAKE_COMMAND}" -E env "PATH=${env_path}${QT_PATH_SEPARATOR}$ENV{PATH}" + "$<TARGET_FILE:appman-dumpqmltypes>" "${CMAKE_SOURCE_DIR}/qmltypes" + COMMENT "Generating qmltypes using appman-dumpqmltypes" + VERBATIM + ) +endif() + +# install the qmltypes set(qml_install_dir "${INSTALL_QMLDIR}") qt_path_join(qml_install_dir ${QT_INSTALL_DIR} ${qml_install_dir}) @@ -30,31 +48,11 @@ if(QT_WILL_INSTALL) DESTINATION "${qml_install_dir}" ) else() - set(COPY_COMMAND COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_SOURCE_DIR}/qmltypes" "${qml_install_dir}") -endif() - -if(TARGET ${target_name} AND NOT QT_FEATURE_cross_compile) - qt_internal_collect_command_environment(env_path env_plugin_path) - - # We have to set the env to get the PATH set to find the Qt libraries - # needed by the appman-dumpqmltypes binary (we cannot guarantee that the - # target is in $QTDIR/bin) - # In addition $<TARGET_FILE:...> will result in a broken path to the - # tool in a multi-config build, because Qt only builds the tools once. - # Hence we need to construct the path to the tool ourselves (copied from - # QtToolHelpers.cmake) - - set(tool_path "${QT_BUILD_DIR}/${INSTALL_BINDIR}/appman-dumpqmltypes") - add_custom_command( - TARGET ${target_name} + TARGET appman-dumpqmltypes POST_BUILD - BYPRODUCTS "qmltypes" - COMMAND "${CMAKE_COMMAND}" -E env "PATH=${env_path}${QT_PATH_SEPARATOR}$ENV{PATH}" - "${tool_path}" "${CMAKE_SOURCE_DIR}/qmltypes" - ${COPY_COMMAND} - DEPENDS "${tool_path}" - COMMENT "Generating qmltypes using ${tool_path}" + COMMAND "${CMAKE_COMMAND}" -E copy_directory "${CMAKE_SOURCE_DIR}/qmltypes" "${qml_install_dir}" + COMMENT "Copying qmltypes to Qt directory" VERBATIM ) endif() diff --git a/src/tools/launcher-qml/CMakeLists.txt b/src/tools/launcher-qml/CMakeLists.txt index 99bc41ca..eb7567be 100644 --- a/src/tools/launcher-qml/CMakeLists.txt +++ b/src/tools/launcher-qml/CMakeLists.txt @@ -1,8 +1,6 @@ -qt_get_tool_target_name(target_name appman-launcher-qml) -qt_internal_add_tool(${target_name} +qt_internal_add_app(appman-launcher-qml EXCEPTIONS - TOOLS_TARGET AppManMainPrivate SOURCES launcher-qml.cpp launcher-qml_p.h PUBLIC_LIBRARIES diff --git a/src/tools/testrunner/CMakeLists.txt b/src/tools/testrunner/CMakeLists.txt index 5f2803d4..362b5df2 100644 --- a/src/tools/testrunner/CMakeLists.txt +++ b/src/tools/testrunner/CMakeLists.txt @@ -1,8 +1,6 @@ -qt_get_tool_target_name(target_name appman-qmltestrunner) -qt_internal_add_tool(${target_name} +qt_internal_add_app(appman-qmltestrunner EXCEPTIONS - TOOLS_TARGET AppManMainPrivate SOURCES ../appman/appman.cpp amtest.cpp amtest.h @@ -17,8 +15,6 @@ qt_internal_add_tool(${target_name} Qt::AppManMainPrivate ) -if (TARGET ${target_name}) - include(QtAppManBuildConfig) +include(QtAppManBuildConfig) - qtam_internal_add_build_config(${target_name}) -endif() +qtam_internal_add_build_config(appman-qmltestrunner) diff --git a/tests/data/CMakeLists.txt b/tests/data/CMakeLists.txt index a5455780..771e09c5 100644 --- a/tests/data/CMakeLists.txt +++ b/tests/data/CMakeLists.txt @@ -44,12 +44,14 @@ 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. + find_package(Qt6 COMPONENTS AppManMainPrivateTools) 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() + find_package(Qt6 COMPONENTS AppManMainPrivateTools) 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> |