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

cmake's qt6_add_executable should not call target_link_libraries

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • Not Evaluated
    • None
    • 6.4.1
    • Build System: CMake
    • None
    • Linux
    • All

    Description

      Using the qt6_add_executable() cmake statement implicitly calls target_link_libraries(). The documentation even says so.

       

      Unfortunately this is utterly unhelpful because most apps won't just want the one library added that the Qt cmake script adds. And cmake doesn't allow calling the target_link_libraries multiple times without generating an error.

       CMake Error at CMakeLists.txt:188 (target_link_libraries):
      The keyword signature for target_link_libraries has already been used with
      the target "pay". All uses of target_link_libraries with a target must be
      either all-keyword or all-plain.

      The uses of the keyword signature are here:

      • /usr/lib/cmake/Qt6Core/Qt6CoreMacros.cmake:549 (target_link_libraries)

       The Qt docs work around this by suggesting to add some libraries PRIVATE. But that doesn't work if you add a bunch of libraries which already have their own target_link_libraries set out of your control.

      Please remove the useless and harmful "helping" call to target_link_libraries in the Qt6CoreMacros.cmake file.

      Attachments

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

        Activity

          People

            tomz Tom Zander
            tomz Tom Zander
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes