# --- T2-COPYRIGHT-BEGIN --- # t2/package/*/meson/hotfix-qt-sysroot.patch # Copyright (C) 2026 The T2 SDE Project # SPDX-License-Identifier: GPL-2.0 or patched project license # --- T2-COPYRIGHT-END --- Backport of upstream 9874cbc9, 33bacc62 and d12465d9 (meson #15456): apply the sys_root to the Qt pkg-config includedir, no host private header dir fallback. --- meson-1.12.1/mesonbuild/dependencies/qt.py +++ meson-1.12.1/mesonbuild/dependencies/qt.py @@ -29,6 +29,13 @@ if T.TYPE_CHECKING: from .base import DependencyObjectKWs +def _qt_sys_root_path(env: 'Environment', for_machine: mesonlib.MachineChoice, path: str) -> str: + from ..scripts import destdir_join + sysroot = env.properties[for_machine].get_sys_root() + if path and sysroot and not mesonlib.path_is_in_root(Path(path), Path(sysroot)): + path = destdir_join(sysroot, path) + return path + def _qt_get_private_includes(mod_inc_dir: str, module: str, mod_version: str) -> T.List[str]: # usually Qt5 puts private headers in /QT_INSTALL_HEADERS/module/VERSION/module/private # except for at least QtWebkit and Enginio where the module version doesn't match Qt version @@ -43,15 +50,6 @@ def _qt_get_private_includes(mod_inc_dir return [] private_dir = os.path.join(mod_inc_dir, mod_version) - # fallback, let's try to find a directory with the latest version - if os.path.isdir(mod_inc_dir) and not os.path.exists(private_dir): - dirs = [filename for filename in os.listdir(mod_inc_dir) - if os.path.isdir(os.path.join(mod_inc_dir, filename))] - - for dirname in sorted(dirs, reverse=True): - if len(dirname.split('.')) == 3: - private_dir = dirname - break return [private_dir, Path(private_dir, f'Qt{module}').as_posix()] @@ -193,9 +191,11 @@ class QtPkgConfigDependency(_QtBase, Pkg self.is_found = False return if self.private_headers: + # fd.o pkg-config does not apply PKG_CONFIG_SYSROOT_DIR to variables. qt_inc_dir = mod.get_variable(pkgconfig='includedir') + qt_inc_dir = _qt_sys_root_path(self.env, self.for_machine, qt_inc_dir) mod_private_dir = os.path.join(qt_inc_dir, 'Qt' + m) - if not os.path.isdir(mod_private_dir): + if not os.path.isdir(os.path.join(mod_private_dir, mod.version)): if self.env.machines[self.for_machine].is_darwin(): # On macOS Qt is conventionally shipped as a framework # (e.g. Homebrew's qt@6). pkg-config 'includedir' is @@ -203,6 +203,7 @@ class QtPkgConfigDependency(_QtBase, Pkg # headers; both public and private headers live under # /Qt.framework/Headers. libdir = mod.get_variable(pkgconfig='libdir', default_value='') + libdir = _qt_sys_root_path(self.env, self.for_machine, libdir) framework_inc = os.path.join(libdir, f'Qt{m}.framework', 'Headers') if libdir and os.path.isdir(framework_inc): mod_private_dir = framework_inc