Details
-
Bug
-
Resolution: Done
-
P2: Important
-
None
-
6.0
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
- is required for
-
QTBUG-85983 Qt6 Android build with cmake
-
- Closed
-
- relates to
-
QTBUG-87951 hardcoded pkg-config settings injected when crosscompiling
-
- Closed
-