]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
cmake: Detect backtrace() support on platforms such as FreeBSD
authorAlex Richardson <arichardson.kde@gmail.com>
Sun, 20 Mar 2022 23:25:29 +0000 (23:25 +0000)
committerRalf Habacker <ralf.habacker@freenet.de>
Thu, 24 Mar 2022 13:41:19 +0000 (13:41 +0000)
On FreeBSD use of backtrace requires linking libexecinfo. The current
check_symbol_exists() will fail due to that missing library. Fortunately,
CMake ships with a FindBacktrace module (at least since 3.0) that can
be used to correctly handle platforms such as FreeBSD (and OpenBSD
according to the FindBacktrace source).

cmake/ConfigureChecks.cmake
dbus/CMakeLists.txt

index 7e21e0841061be4fb7f882f8092bf23a184d8650..45136cc33bbc1dc43260765354a1f09d89bfdbd8 100644 (file)
@@ -42,7 +42,9 @@ check_include_file(ws2tcpip.h   HAVE_WS2TCPIP_H)# dbus-sysdeps-win.c
 check_include_file(unistd.h     HAVE_UNISTD_H)  # dbus-sysdeps-util-win.c
 check_include_file(sys/inotify.h DBUS_BUS_ENABLE_INOTIFY)
 
-check_symbol_exists(backtrace    "execinfo.h"       HAVE_BACKTRACE)          #  dbus-sysdeps.c, dbus-sysdeps-win.c
+find_package(Backtrace)  # dbus-sysdeps.c, dbus-sysdeps-win.c
+set(HAVE_BACKTRACE ${Backtrace_FOUND})
+
 check_symbol_exists(getgrouplist "grp.h"            HAVE_GETGROUPLIST)       #  dbus-sysdeps.c
 check_symbol_exists(getpeerucred "ucred.h"          HAVE_GETPEERUCRED)       #  dbus-sysdeps.c, dbus-sysdeps-win.c
 check_symbol_exists(nanosleep    "time.h"           HAVE_NANOSLEEP)          #  dbus-sysdeps.c
index e9203ca67c3c4a7142c9abea2553abc720e5a04d..9e3f0a148eb0f8f506e2d3178258bcc60f358538 100644 (file)
@@ -292,6 +292,10 @@ else(WIN32)
     if(LIBSOCKET)
         target_link_libraries(dbus-1 ${LIBSOCKET})
     endif()
+    if (HAVE_BACKTRACE)
+        target_link_libraries(dbus-1 ${Backtrace_LIBRARY})
+        target_include_directories(dbus-1 PRIVATE ${Backtrace_INCLUDE_DIR})
+    endif()
 endif()
 
 target_include_directories(dbus-1 INTERFACE $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/dbus-1.0>;$<INSTALL_INTERFACE:${CMAKE_INSTALL_LIBDIR}/dbus-1.0/include>)