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

Address CMake Policy CMP0156 warnings for qt builds and user projects

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 6.7
    • Build System: CMake
    • None

    Description

      When building Qt, or user projects that use Qt with CMake 3.29 when --trace option is passed, you get warnings like:

      Make Warning (dev) at /Users/alex/Dev/qt/builds/dev-mac-newcm/qtbase/lib/cmake/Qt6Core/Qt6CoreMacros.cmake:676 (add_executable):
        Policy CMP0156 is not set: De-duplicate libraries on link lines based on
        linker capabilities.  Run "cmake --help-policy CMP0156" for policy details.
        Use the cmake_policy command to set the policy and suppress this warning.
      
        Since the policy is not set, legacy libraries de-duplication strategy will
        be applied.
      Call Stack (most recent call first):
        /Users/alex/Dev/qt/builds/dev-mac-newcm/qtbase/lib/cmake/Qt6Core/Qt6CoreMacros.cmake:622 (_qt_internal_create_executable)
        /Users/alex/Dev/qt/builds/dev-mac-newcm/qtbase/lib/cmake/Qt6Core/Qt6CoreMacros.cmake:916 (qt6_add_executable)
        CMakeLists.txt:11 (qt_add_executable)
      This warning is for project developers.  Use -Wno-dev to suppress it.
      

      Until we decide that setting the policy to NEW is safe for Qt, we should:

      • set the policy to OLD for Qt builds
      • either set the policy to OLD for user projects, or provide documentation how they can do it.

      If we set it for user projects, we should also allow an opt out, in case users know better.

      Where to set the policy for user projects is pending investigation.
      There are a few candidate locations:

      • in all qt_add_library / qt_add_executable calls, etc
      • in qt_project_standard_setup
      • in find_package(Qt6) (unclear if possible)

      Also need to find the best place in Qt build, so we don't repeat it in each repo.

      The warnings don't appear when configuring a project without --trace, so it's not super critical in my opinion.

      Attachments

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

        Activity

          People

            qtbuildsystem Qt Build System Team
            alexandru.croitor Alexandru Croitor
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes