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

pkg-config should not look for host libraries when cross-compiling

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • None
    • 6.0
    • Build System: CMake

    Description

      This code block in qtbase/CMakeLists.txt is problematic

      if (CMAKE_CROSSCOMPILING AND CMAKE_SYSROOT)
          # When cross compiling with CMake any calls to pkg_check_modules() will
          # search into the host system instead of the target sysroot.
          # The current work around is based on the discussion found at
          # https://gitlab.kitware.com/cmake/cmake/-/merge_requests/4478
          set(ENV{PKG_CONFIG_DIR} "")
          set(ENV{PKG_CONFIG_LIBDIR} "${CMAKE_SYSROOT}/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig")
          set(ENV{PKG_CONFIG_SYSROOT_DIR} ${CMAKE_SYSROOT})
      endif()
      

      The first problem is that CMAKE_SYSROOT is usually set by the toolchain file, but the toolchain file is first loaded when a project() call is encountered, which is below this block of code. That means CMAKE_SYSROOT is empty, and the code is never applied.

      The second problem is that this should be done for all repos, not just qtbase, as well as for consuming public projects.
      Most likely this needs to go either into Qt6CoreConfigExtras or QtBuildInternalsExtra.

      I'm thinking the former, because our Find scripts use pkg-config to find 3rd party dependencies, and we need to ensure when cross compiling to Android or iOS or embedded linux, the host libs should not be found.

      In fact we might need to add it to Qt6ConfigExtras, because by the time Qt6CoreConfigExtras is loaded, there might have already been pkg_check_modules

      Attachments

        Issue Links

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

          Activity

            People

              alexandru.croitor Alexandru Croitor
              alexandru.croitor Alexandru Croitor
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes