Skip to content

cmake: Look for dbus-arch-deps.h next to DBus1Config.cmake

Simon McVittie requested to merge smcv/dbus:wip/find-arch-include-dir into master

<dbus/dbus-arch-deps.h> is architecture-dependent, and compilers have not traditionally supported an installation path for architecture-specific headers (Debian-based systems have /usr/include/${multiarch_tuple}, but that isn't portable beyond Debian). When dbus was built using Autotools, dependent projects that use CMake need to look for this header in the right place.

Unfortunately, it seems that at least recent versions of CMake will ignore the HINTS we get from pkg-config if they are told to search in a non-standard prefix via ${DBus1_ROOT}.

Look for dbus-arch-deps.h in a directory derived from the filename of the CMake config file, before trying the normal search algorithm. The CMake config file is in ${libdir}, and so is the architecture-specific header, so this should work reasonably reliably.

According to the CMake documentation, if we search for the same thing multiple times, the first successful result will be used; and searching with NO_DEFAULT_PATH is the official way to prepend things to the search order.

Resolves: #314 (closed)


/cc @rhabacker

Edited by Simon McVittie

Merge request reports