Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-88840

No way to pass QT_ANDROID_PACKAGE_SOURCE_DIR for qt6_add_executable

    XMLWordPrintable

    Details

    • Platform/s:
      Android
    • Commits:
      b94b7687b0635ee74a3ccd83a234ead0600fd47f (qt/qtbase/dev) 3c8d95afa56e9787f222086b1918616aeb9d5337 (qt/qtbase/6.0)

      Description

      qt6_add_executable()

      automatically immediately calls

      qt_android_generate_deployment_settings()

      when targeting Android.

      That function reads properties off the executable target, like

      QT_ANDROID_PACKAGE_SOURCE_DIR
      QT_ANDROID_EXTRA_PLUGINS

      etc.

      The user project has no opportunity to set these properties, because properties can't be set on a target doesn't exist. And trying to set them after the qt6_add_executable call is too late.

      A workaround, is to manually call the qt6_android_generate_deployment_settings function after calling qt6_add_executable, and setting the necessary properties.

      Thus, the existing qt6_add_executable API is suboptimal.
      But the available options to change it are also suboptimal, and we need to pick one that we consider is the best one going forward.

      Possible options

      1. Change qt6_add_executable not to call qt_android_generate_deployment_settings automatically in its implementation, so you can set the properties after qt_add_executable, and then call the function manually. Downside is, user needs to know to call the function manually.
      2. allow additional options to qt6_add_executable, which would set the properties inside its implementation, so the automatic call of qt_android_generate_deployment_settings find what it needs. This is a suboptimal solution API wise, because it will bloat the list of options that qt_add_executable is supposed to take
      3. Use CMake 3.19's cmake_language(DEFER CALL) to defer the call to the android deployment json file generation. We can't use this always because minimum CMake version to use Qt is 3.14.
      4. Use the approach from Qt5, where instead of setting target properties, a user project will have to set CMake variables like set(QT_ANDROID_PACKAGE_SOURCE_DIR"${​​​​​​​​CMAKE_CURRENT_SOURCE_DIR}​​​​​​​​/android") before the qt_add_executable call. Downside is that it pollutes the project directory and subdirectories, and is not tied to a target.

        Attachments

          Issue Links

          For Gerrit Dashboard: QTBUG-88840
          # Subject Branch Project Status CR V

            Activity

              People

              Assignee:
              crscott Craig Scott
              Reporter:
              alexandru.croitor Alexandru Croitor
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Gerrit Reviews

                  There are no open Gerrit changes