Use pkg-configs imported target to link against DBus

To use -ldbus, the value of ${DBus_LIBARARY_DIR} would also need to be
added to the linker search paths.

To get around this, simply use the imported target by pkgconfig.

[1] b8b30ba571
This commit is contained in:
Tobias C. Berner 2024-01-07 11:42:23 +01:00
parent 55fe336ee4
commit e7fd4257bf
2 changed files with 2 additions and 5 deletions

View file

@ -78,7 +78,7 @@ if(UNIX AND NOT APPLE)
find_package(WaylandProtocols REQUIRED) find_package(WaylandProtocols REQUIRED)
pkg_check_modules(XkbCommon IMPORTED_TARGET xkbcommon) pkg_check_modules(XkbCommon IMPORTED_TARGET xkbcommon)
find_package(PkgConfig QUIET REQUIRED) find_package(PkgConfig QUIET REQUIRED)
pkg_check_modules(DBus REQUIRED dbus-1) pkg_check_modules(DBus REQUIRED IMPORTED_TARGET dbus-1)
endif() endif()
if (NOT WIN32) if (NOT WIN32)

View file

@ -20,10 +20,7 @@ target_sources(kdeconnect_sendnotifications PRIVATE windowsnotificationslistener
target_link_libraries(kdeconnect_sendnotifications runtimeobject windowsapp) target_link_libraries(kdeconnect_sendnotifications runtimeobject windowsapp)
else() else()
target_sources(kdeconnect_sendnotifications PRIVATE dbusnotificationslistener.cpp) target_sources(kdeconnect_sendnotifications PRIVATE dbusnotificationslistener.cpp)
target_link_libraries(kdeconnect_sendnotifications ${DBus_LIBRARIES}) target_link_libraries(kdeconnect_sendnotifications PkgConfig::DBus)
target_include_directories(kdeconnect_sendnotifications
SYSTEM PRIVATE ${DBus_INCLUDE_DIRS}
)
endif() endif()
# Config # Config