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

    • Type: Suggestion
    • Status: Reported
    • Priority: Not Evaluated
    • Resolution: Unresolved
    • Affects Version/s: 5.15.2
    • Fix Version/s: None
    • Component/s: Documentation
    • Labels:
      None

      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

            Assignee:
            docteam Qt Documentation Team
            Reporter:
            talkless Vincas Dargis
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:

                Gerrit Reviews

                There are no open Gerrit changes