Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-25175

qt_add_executable ignores ANDROID_PACKAGE_SOURCE_DIR

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Reported
    • Priority: Not Evaluated
    • Resolution: Unresolved
    • Affects Version/s: Qt Creator 4.14.0
    • Fix Version/s: None
    • Component/s: Android Support
    • Labels:
      None
    • Platform/s:
      Android

      Description

      Hi

       

      When a project created by QT Creator (CMake+Android), qt_add_executable ignores ANDROID_PACKAGE_SOURCE_DIR. Any custome changes for android (e.g. AndroidManifest.xml) does not affect the generated APK.

       

      When compiling the following example, QT Creator (CMake+Android) does not copy content of  `"${CMAKE_CURRENT_SOURCE_DIR}/android"` to "build-untitled...\android-build\".

       

      For example custome "AndroidManifest.xml" never used:

       

      ```

      cmake_minimum_required(VERSION 3.14)

      project(untitled LANGUAGES CXX)

      set(CMAKE_INCLUDE_CURRENT_DIR ON)

      set(CMAKE_AUTOUIC ON)
      set(CMAKE_AUTOMOC ON)
      set(CMAKE_AUTORCC ON)

      set(CMAKE_CXX_STANDARD 11)
      set(CMAKE_CXX_STANDARD_REQUIRED ON)

      if(ANDROID)
      set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
      endif()

      find_package(Qt6 COMPONENTS Core Quick REQUIRED)

      set(PROJECT_SOURCES
      main.cpp
      qml.qrc)

      qt_add_executable(untitled ${PROJECT_SOURCES})

      target_link_libraries(untitled PRIVATE Qt6::Core Qt6::Quick)

      ```

       

      I try to solve the bug manually:

       

      ```

      function(qt_add_executable_no_bug target)
      if(ANDROID)
      add_library("${target}" MODULE ${ARGN})
      set_property(TARGET "${target}" PROPERTY C_VISIBILITY_PRESET default)
      set_property(TARGET "${target}" PROPERTY CXX_VISIBILITY_PRESET default)
      set_property(TARGET "${target}" PROPERTY OBJC_VISIBILITY_PRESET default)
      set_property(TARGET "${target}" PROPERTY OBJCXX_VISIBILITY_PRESET default)
      qt6_android_apply_arch_suffix("${target}")
      else()
      add_executable("${target}" ${ARGN})
      endif()
      target_link_libraries("${target}" PRIVATE Qt::Core)

      if(ANDROID)
      set_property(TARGET "${target}" PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR ${ANDROID_PACKAGE_SOURCE_DIR})
      qt_android_generate_deployment_settings("${target}")
      qt_android_add_apk_target("${target}")
      endif()
      endfunction()

      ```

       

      Thanks

        Attachments

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

          Activity

            People

            Assignee:
            portale Alessandro Portale
            Reporter:
            amir_saniyan Amir Saniyan
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:

                Gerrit Reviews

                There are no open Gerrit changes