From 33bc728d3a6795a58174019d530f49b7dec3ac94 Mon Sep 17 00:00:00 2001 From: Jan Beich Date: Fri, 8 Sep 2023 19:51:01 +0200 Subject: [PATCH] chore: don't use systemd headers with elogind In file included from src/VTableUtils.c:27: src/VTableUtils.h:30:10: fatal error: 'systemd/sd-bus.h' file not found #include ^~~~~~~~~~~~~~~~~~ --- CMakeLists.txt | 9 ++++++--- src/Connection.cpp | 2 +- src/Connection.h | 2 +- src/Error.cpp | 2 +- src/Flags.cpp | 2 +- src/IConnection.h | 2 +- src/ISdBus.h | 2 +- src/Message.cpp | 2 +- src/Object.cpp | 2 +- src/Object.h | 2 +- src/Proxy.cpp | 2 +- src/Proxy.h | 2 +- src/Types.cpp | 2 +- src/Utils.h | 2 +- src/VTableUtils.c | 2 +- src/VTableUtils.h | 2 +- tests/CMakeLists.txt | 8 ++++++-- 17 files changed, 27 insertions(+), 20 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bbe61b9..9fe9b11 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,7 @@ include(GNUInstallDirs) # Installation directories for `install` command and pkg # PERFORMING CHECKS & PREPARING THE DEPENDENCIES #------------------------------- -set(LIBSYSTEMD "libsystemd") +set(LIBSYSTEMD "systemd") option(BUILD_LIBSYSTEMD "Build libsystemd static library and incorporate it into libsdbus-c++" OFF) @@ -23,7 +23,7 @@ if(NOT BUILD_LIBSYSTEMD) message(WARNING "libsystemd not found, checking for libelogind instead") pkg_check_modules(Systemd IMPORTED_TARGET GLOBAL libelogind>=236) if(TARGET PkgConfig::Systemd) - set(LIBSYSTEMD "libelogind") + set(LIBSYSTEMD "elogind") string(REPLACE "." ";" VERSION_LIST ${Systemd_VERSION}) list(GET VERSION_LIST 0 Systemd_VERSION) endif() @@ -116,7 +116,10 @@ endif() # Having an object target allows unit tests to reuse already built sources without re-building add_library(sdbus-c++-objlib OBJECT ${SDBUSCPP_SRCS}) -target_compile_definitions(sdbus-c++-objlib PRIVATE BUILD_LIB=1 LIBSYSTEMD_VERSION=${LIBSYSTEMD_VERSION}) +target_compile_definitions(sdbus-c++-objlib PRIVATE + BUILD_LIB=1 + LIBSYSTEMD_VERSION=${LIBSYSTEMD_VERSION} + SDBUS_HEADER=<${LIBSYSTEMD}/sd-bus.h>) target_include_directories(sdbus-c++-objlib PUBLIC $ $) if(DEFINED BUILD_SHARED_LIBS) diff --git a/src/Connection.cpp b/src/Connection.cpp index d235ed1..dea217c 100644 --- a/src/Connection.cpp +++ b/src/Connection.cpp @@ -31,7 +31,7 @@ #include #include #include "ScopeGuard.h" -#include +#include SDBUS_HEADER #include #include #include diff --git a/src/Connection.h b/src/Connection.h index 445c915..c69627b 100644 --- a/src/Connection.h +++ b/src/Connection.h @@ -32,7 +32,7 @@ #include "IConnection.h" #include "ScopeGuard.h" #include "ISdBus.h" -#include +#include SDBUS_HEADER #include #include #include diff --git a/src/Error.cpp b/src/Error.cpp index e4a1f14..11625cb 100644 --- a/src/Error.cpp +++ b/src/Error.cpp @@ -25,7 +25,7 @@ */ #include -#include +#include SDBUS_HEADER #include "ScopeGuard.h" namespace sdbus diff --git a/src/Flags.cpp b/src/Flags.cpp index 3b7b8d6..ca20d5c 100644 --- a/src/Flags.cpp +++ b/src/Flags.cpp @@ -25,7 +25,7 @@ */ #include -#include +#include SDBUS_HEADER namespace sdbus { diff --git a/src/IConnection.h b/src/IConnection.h index 74b7832..1c23bbe 100644 --- a/src/IConnection.h +++ b/src/IConnection.h @@ -28,7 +28,7 @@ #define SDBUS_CXX_INTERNAL_ICONNECTION_H_ #include -#include +#include SDBUS_HEADER #include #include #include diff --git a/src/ISdBus.h b/src/ISdBus.h index 5fdd352..9ca8f3f 100644 --- a/src/ISdBus.h +++ b/src/ISdBus.h @@ -28,7 +28,7 @@ #ifndef SDBUS_CXX_ISDBUS_H #define SDBUS_CXX_ISDBUS_H -#include +#include SDBUS_HEADER namespace sdbus::internal { diff --git a/src/Message.cpp b/src/Message.cpp index b68801d..c45493e 100644 --- a/src/Message.cpp +++ b/src/Message.cpp @@ -31,7 +31,7 @@ #include "ISdBus.h" #include "IConnection.h" #include "ScopeGuard.h" -#include +#include SDBUS_HEADER #include namespace sdbus { diff --git a/src/Object.cpp b/src/Object.cpp index 6b6b3be..c6df821 100644 --- a/src/Object.cpp +++ b/src/Object.cpp @@ -35,7 +35,7 @@ #include "IConnection.h" #include "Utils.h" #include "VTableUtils.h" -#include +#include SDBUS_HEADER #include #include diff --git a/src/Object.h b/src/Object.h index aad5c4c..c22abe2 100644 --- a/src/Object.h +++ b/src/Object.h @@ -29,7 +29,7 @@ #include #include "IConnection.h" -#include +#include SDBUS_HEADER #include #include #include diff --git a/src/Proxy.cpp b/src/Proxy.cpp index 061b620..8a760ca 100644 --- a/src/Proxy.cpp +++ b/src/Proxy.cpp @@ -32,7 +32,7 @@ #include "sdbus-c++/IConnection.h" #include "sdbus-c++/Error.h" #include "ScopeGuard.h" -#include +#include SDBUS_HEADER #include #include #include diff --git a/src/Proxy.h b/src/Proxy.h index b0c4fac..f11f059 100644 --- a/src/Proxy.h +++ b/src/Proxy.h @@ -29,7 +29,7 @@ #include #include "IConnection.h" -#include +#include SDBUS_HEADER #include #include #include diff --git a/src/Types.cpp b/src/Types.cpp index ca8f4a2..5e4cc65 100644 --- a/src/Types.cpp +++ b/src/Types.cpp @@ -27,7 +27,7 @@ #include #include #include "MessageUtils.h" -#include +#include SDBUS_HEADER #include namespace sdbus { diff --git a/src/Utils.h b/src/Utils.h index 7c044e3..277ca91 100644 --- a/src/Utils.h +++ b/src/Utils.h @@ -28,7 +28,7 @@ #define SDBUS_CXX_INTERNAL_UTILS_H_ #include -#include +#include SDBUS_HEADER #if LIBSYSTEMD_VERSION>=246 #define SDBUS_CHECK_OBJECT_PATH(_PATH) \ diff --git a/src/VTableUtils.c b/src/VTableUtils.c index a10f027..e848faf 100644 --- a/src/VTableUtils.c +++ b/src/VTableUtils.c @@ -25,7 +25,7 @@ */ #include "VTableUtils.h" -#include +#include SDBUS_HEADER sd_bus_vtable createVTableStartItem(uint64_t flags) { diff --git a/src/VTableUtils.h b/src/VTableUtils.h index bf34666..03bdf31 100644 --- a/src/VTableUtils.h +++ b/src/VTableUtils.h @@ -27,7 +27,7 @@ #ifndef SDBUS_CXX_INTERNAL_VTABLEUTILS_H_ #define SDBUS_CXX_INTERNAL_VTABLEUTILS_H_ -#include +#include SDBUS_HEADER #include #ifdef __cplusplus diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 25ed6cd..8123daa 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -104,11 +104,15 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}) #---------------------------------- add_executable(sdbus-c++-unit-tests ${UNITTESTS_SRCS}) -target_compile_definitions(sdbus-c++-unit-tests PRIVATE LIBSYSTEMD_VERSION=${LIBSYSTEMD_VERSION}) +target_compile_definitions(sdbus-c++-unit-tests PRIVATE + LIBSYSTEMD_VERSION=${LIBSYSTEMD_VERSION} + SDBUS_HEADER=<${LIBSYSTEMD}/sd-bus.h>) target_link_libraries(sdbus-c++-unit-tests sdbus-c++-objlib GTest::gmock) add_executable(sdbus-c++-integration-tests ${INTEGRATIONTESTS_SRCS}) -target_compile_definitions(sdbus-c++-integration-tests PRIVATE LIBSYSTEMD_VERSION=${LIBSYSTEMD_VERSION}) +target_compile_definitions(sdbus-c++-integration-tests PRIVATE + LIBSYSTEMD_VERSION=${LIBSYSTEMD_VERSION} + SDBUS_HEADER=<${LIBSYSTEMD}/sd-bus.h>) target_link_libraries(sdbus-c++-integration-tests sdbus-c++ GTest::gmock) # Manual performance and stress tests