cmake: support sd-bus fallback implementations

* elogind: https://github.com/elogind/elogind
* basu: https://github.com/emersion/basu

Relates https://github.com/clangen/musikcube/issues/365
Fixes https://github.com/clangen/musikcube/issues/456

Signed-off-by: Robert Günzler <r@gnzler.io>
This commit is contained in:
Robert Günzler 2021-10-27 13:01:12 +02:00
parent e2574cc1f4
commit aa12ef18bb
No known key found for this signature in database
GPG Key ID: 2143BD2AAB94BCC4
2 changed files with 17 additions and 17 deletions

View File

@ -154,21 +154,6 @@ else()
add_dependencies(musikcube ffmpegdecoder) add_dependencies(musikcube ffmpegdecoder)
endif() endif()
# systemd / MPRIS detection
if (NOT ENABLE_MPRIS MATCHES "false")
find_library(LIB_SYSTEMD NAMES systemd)
if (NOT LIB_SYSTEMD MATCHES "LIB_SYSTEMD-NOTFOUND")
message(STATUS "[mpris] systemd found at " ${LIB_SYSTEMD})
message(STATUS "[mpris] setting ENABLE_MPRIS=true")
set(ENABLE_MPRIS "true")
else()
message(STATUS "[mpris] systemd *not* found. MPRIS plugin not enabled")
set(ENABLE_MPRIS "false")
endif()
endif()
#end systemd / MPRIS detection
add_dependencies(musikcube musikcore taglibreader nullout server httpdatastream stockencoders) add_dependencies(musikcube musikcore taglibreader nullout server httpdatastream stockencoders)
add_dependencies(musikcubed musikcube) add_dependencies(musikcubed musikcube)

View File

@ -2,8 +2,23 @@ set (mpris_SOURCES
mpris.cpp mpris.cpp
dbus.cpp) dbus.cpp)
if (USE_ELOGIND MATCHES "true")
ensure_library_exists(elogind >= 239.3)
set(SDBUS "libelogind >= 239.3")
elseif (USE_BASU MATCHES "true")
ensure_library_exists(basu)
set(SDBUS "basu")
else()
ensure_library_exists(systemd)
set(SDBUS "libsystemd")
endif()
message(STATUS "[mpris] plugin enabled")
find_package(PkgConfig) find_package(PkgConfig)
pkg_check_modules (SYSTEMD REQUIRED libsystemd) pkg_check_modules(SDBUS REQUIRED IMPORTED_TARGET ${SDBUS})
add_library(mpris SHARED ${mpris_SOURCES}) add_library(mpris SHARED ${mpris_SOURCES})
target_link_libraries(mpris ${musikcube_LINK_LIBS} systemd) target_link_libraries(mpris ${musikcube_LINK_LIBS} PkgConfig::SDBUS)