[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#1121850: cmake: Debian cross builds fail when using cmake_pkg_config



Package: cmake
Version: 3.31.6-2
Severity: important
X-Debbugs-Cc: debian-cross@lists.debian.org
User: debian-cross@lists.debian.org
Usertags: ftcbfs
Control: affects -1 + src:endless-sky

Hi Timo and others,

CMake gained a new "cmake_pkg_config". It's not a macro, but a builtin
and it effectively reimplements pkgconf and pkg-config. As with many
reimplementations, this one also is feature-incomplete. When performing
a Debian package cross build, cmake_pkg_config fails to locate
dependencies, because it ends up using the build architecture .pc search
path. For example, when building endless-sky, minizip is not found
despite being properly installed.

It is not clear how to fix this. debhelper export the PKG_CONFIG
environment variable and sets both CMake variables PKG_CONFIG_EXECUTABLE
and PKGCONFIG_EXECUTABLE, but apparently that is not enough. When I
looked into it, it seemed as if it were actually querying
CMAKE_PKG_CONFIG_BIN, but setting that doesn't make it work either. It
is fairly evident from a failing build log by looking at the resulting
CMAKE_PKG_CONFIG_PC_LIB_DIRS. On the flip side, setting
CMAKE_PKG_CONFIG_PC_LIB_DIRS=/usr/lib/${DEB_HOST_MULTIARCH}/pkgconfig;/usr/share/pkgconfig
makes cmake_pkg_config work. The recommended way to properly discover
this value is pkg-config --variable=pc_path pkg-config, but this gives
us the path for pkg-config's architecture. It is where pkgconf stops
being Multi-Arch:foreign:

$ bash -c 'exec -a aarch64-linux-gnu-pkgconf pkgconf --variable=pc_path pkg-config'
/usr/local/lib/x86_64-linux-gnu/pkgconfig:/usr/local/lib/pkgconfig:/usr/local/share/pkgconfig:/usr/lib/x86_64-linux-gnu/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig
$

So it's not that obvious how to communicate this to CMake and where to
do this. For instance, extending debhelper with yet another assignment
may be a sensible option.

So for now, I'm documenting the problem hoping that others chime in and
provide feedback on how this is supposed to work in theory.

Helmut


Reply to: