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

CMake configuration fails with multiple calls to find_package(Qt)

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Reported
    • Priority: P1: Critical
    • Resolution: Unresolved
    • Affects Version/s: 5.15.1
    • Fix Version/s: None
    • Component/s: Build System: CMake
    • Labels:
      None
    • Platform/s:
      Android

      Description

      Hi

      I'm trying to build my project, which consists of an app and a few libraries, for Android. I'm building with CMake, there's no qmake nor QtCreator.

      I get the following error at configure time:

      CMake Error at C:/dev/qt/5.15.1/android/lib/cmake/Qt5Core/Qt5AndroidSupport.cmake:126 (add_custom_target):
        add_custom_target cannot create target "apk" because another target with
        the same name already exists.  The existing target is a custom target
        created in source directory "my-project".  See
        documentation for policy CMP0002 for more details.
      Call Stack (most recent call first):
        C:/dev/qt/5.15.1/android/lib/cmake/Qt5Core/Qt5CoreConfigExtras.cmake:94 (include)
        C:/dev/qt/5.15.1/android/lib/cmake/Qt5Core/Qt5CoreConfig.cmake:232 (include)
        my-project/CMakeLists.txt:28 (find_package)

      It seems that Qt5AndroidSupport.cmake creates two custom CMake targets ("apk" and "aab") whenever it is included by a call to find_package(Qt). Therefore, multiple calls to find_package(Qt) produce this error, as it tries to create the "apk" and "aab" targets multiple times.

      All this was previously working with Qt 5.13.1.

        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:
            laurentgom Laurent
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:

                Gerrit Reviews

                There are no open Gerrit changes