From e2dd13d9061d8c8a212b9f2f0e6503cc7cf60a51 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 6 Nov 2020 14:42:19 +0000 Subject: [PATCH] cmake: Look for dbus-arch-deps.h next to DBus1Config.cmake 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: https://gitlab.freedesktop.org/dbus/dbus/-/issues/314 Signed-off-by: Simon McVittie (cherry picked from commit 104df89947913e97bf4253d7dea53626063f6406) Backported-from: dbus!191 --- cmake/DBus1Config.pkgconfig.in | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmake/DBus1Config.pkgconfig.in b/cmake/DBus1Config.pkgconfig.in index 93c593e1..0f021850 100644 --- a/cmake/DBus1Config.pkgconfig.in +++ b/cmake/DBus1Config.pkgconfig.in @@ -9,6 +9,7 @@ # to a target with target_link_libraries get_filename_component(DBus1_PKGCONFIG_DIR "${CMAKE_CURRENT_LIST_DIR}/../../pkgconfig" ABSOLUTE) +get_filename_component(DBus1_NEARBY_ARCH_INCLUDE_DIR "${CMAKE_CURRENT_LIST_DIR}/../../dbus-1.0/include" ABSOLUTE) find_package(PkgConfig) if(DEFINED ENV{PKG_CONFIG_DIR}) set(_dbus_pkgconfig_dir "$ENV{PKG_CONFIG_DIR}") @@ -50,6 +51,9 @@ set(DBus1_DEFINITIONS ${PC_DBUS1_CFLAGS_OTHER}) find_path(DBus1_INCLUDE_DIR dbus/dbus.h HINTS ${PC_DBUS1_INCLUDEDIR} ${PC_DBUS1_INCLUDE_DIRS} PATH_SUFFIXES dbus-1.0) +find_path(DBus1_ARCH_INCLUDE_DIR dbus/dbus-arch-deps.h + PATHS ${DBus1_NEARBY_ARCH_INCLUDE_DIR} + NO_DEFAULT_PATH) find_path(DBus1_ARCH_INCLUDE_DIR dbus/dbus-arch-deps.h HINTS ${PC_DBUS1_INCLUDE_DIRS} PATH_SUFFIXES dbus-1.0)