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

Note to add CMake variables to the cache in "Deploying an Application on Android"

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Fixed
    • P2: Important
    • None
    • 5.15.2
    • None
    • be76e1431 (tqtc/lts-5.15)
    • 2023wk22FOQtforAndroid

    Description

      I've struggled for more than a day trying to figure out why ANDROID_PACKAGE_SOURCE_DIR does not work with CMake.

       I just get default AndroidManifest file, and android-build/res/* keeps cleared after copying manually.

      Until I found blog post https://www.kdab.com/qtcreator-cmake-for-android-plugin/ that says:

      The CACHE is mandatory, otherwise QtCreator won’t see the variable and it won’t use it
      

      So I have to define variable like this:

      set(ANDROID_PACKAGE_SOURCE_DIR "${PROJECT_SOURCE_DIR}/android" CACHE INTERNAL "")
      

      i.e. adding CACHE..

      Meanwhile, "Deploying an Application on Android" article (https://doc.qt.io/qt-5/deployment-android.html) only says this:

      Note: This list of variables can also be used with CMake.
      

      it would be nice to have note about setting CACHE, or just full example of doing that in CMake.

      Also, if I create new CMake project with QtCreator 4.14, I get this commented block:

      # QtCreator supports the following variables for Android, which are identical to qmake Android variables.
      # Check https://doc.qt.io/qt/deployment-android.html for more information.
      # They need to be set before the find_package(...) calls below.
      
      #if(ANDROID)
      #    set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
      #    if (ANDROID_ABI STREQUAL "armeabi-v7a")
      #        set(ANDROID_EXTRA_LIBS
      #            ${CMAKE_CURRENT_SOURCE_DIR}/path/to/libcrypto.so
      #            ${CMAKE_CURRENT_SOURCE_DIR}/path/to/libssl.so)
      #    endif()
      #endif()
      

      Note that there's no CACHE there too!

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            nick_bennett Nicholas Bennett
            talkless Vincas Dargis
            Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes