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

Invalid deployment of custom android directory with cmake

    XMLWordPrintable

    Details

    • Platform/s:
      Android

      Description

      I created three simple projects for android (cmake_android_problems.zip: test14, test15, test16) using the project wizard from QtCreator.

      All of them contain an android subfolder with its own build.gradle file. This file differs from the standard file only by one line:

      defaultConfig {
              resConfig "de" //!!!!!!!!!!!!!!!!!!!!!!!!! Custom setting
              minSdkVersion = qtMinSdkVersion
              targetSdkVersion = qtTargetSdkVersion
      }
      

       

      All three projects differ in how ANDROID_PACKAGE_SOURCE_DIR in CMakeLists.txt is defined.

      test14:

      Simple activation of a line that was already (commented out) in the generated file.

      ...
           if(ANDROID)
              add_library(test14 SHARED
                  ${PROJECT_SOURCES}
              )
      # Define properties for Android with Qt 5 after find_package() calls as:
              set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
          else()
      ...

      test15:

      Extra flags (CACHE INTERNAL) for property (See: https://www.kdab.com/qtcreator-cmake-for-android-plugin/)

      ...
           if(ANDROID)
              add_library(test15 SHARED
                  ${PROJECT_SOURCES}
              )
      # Define properties for Android with Qt 5 after find_package() calls as:
              set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android" CACHE INTERNAL "")
          else()
      ...

      test16:

      Definition before find_package. Which actually goes against the recommendation in the comment (Define properties for Android with Qt 5 after find_package).

      ...
      if(ANDROID)
          set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
      endif()
      
      find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Quick REQUIRED)
      find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Quick REQUIRED)
      ...
       if(ANDROID)
              add_library(test16 SHARED
                  ${PROJECT_SOURCES}
              )
      # Define properties for Android with Qt 5 after find_package() calls as:
      #    set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
          else()
      ...

       

      And now the results of the build:

      test14:

      • deployed android-build/build.gradle is not the custom adroid subdirectory file

      test15:

      • deployed android-build/build.gradle is not the custom adroid subdirectory file
      • manual call of Run Cmake and build in QtCreator project tree results in proper deployment

      test16:

      • deployment is correct although the property location is theoretically incorrect

       

      Which of these options is correct?

      Regardless of which one, there is definitely some more work required there because either the automatically generated file is not correct or it is not being processed correctly.

       

        Attachments

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

          Activity

            People

            Assignee:
            qtbuildsystem Qt Build System Team
            Reporter:
            permotion88 Karol Polak
            Votes:
            2 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:

                Gerrit Reviews

                There are no open Gerrit changes