]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
cmake: Look for dbus-arch-deps.h next to DBus1Config.cmake
authorSimon McVittie <smcv@collabora.com>
Fri, 6 Nov 2020 14:42:19 +0000 (14:42 +0000)
committerRalf Habacker <ralf.habacker@freenet.de>
Wed, 30 Mar 2022 07:36:38 +0000 (07:36 +0000)
<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: https://gitlab.freedesktop.org/dbus/dbus/-/issues/314
Signed-off-by: Simon McVittie <smcv@collabora.com>
cmake/DBus1Config.pkgconfig.in

index 93c593e1c37b3636a01e62b38cdabecc149b077f..0f0218500b01fa24ec9b4cfa12680b36c468cbf6 100644 (file)
@@ -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)