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

CMake configuration fails with multiple calls to find_package(Qt)

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P1: Critical
    • 5.15.6, 5.15.3
    • 5.15.1, 5.15.2
    • Build System: CMake
    • None
    • Android
    • 265d48f688b4169e60055b15702a90eb54262298 (qt/tqtc-qtbase/5.15)

    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

        Activity

          People

            jbornema Joerg Bornemann
            laurentgom Laurent
            Votes:
            4 Vote for this issue
            Watchers:
            11 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: