Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cmake variables for systemd are empty

I want to start/stop a systemd service from within my C++ project. Therefore I like to use the systemd lib and headers provided. I'm using cmake for makefile generation. I'm trying to get systemd in cmake via

pkg_check_modules(SDBUS REQUIRED systemd)

which actually works as

message(STATUS "FOUND" ${SDBUS_FOUND}) returns 1.

However, all the other necessary vars created by cmake like

message(STATUS "LIBS" ${SDBUS_LIBRARIES})
message(STATUS "LIB_DIRS" ${SDBUS_LIBRARY_DIRS})
message(STATUS "LDFLAGS" ${SDBUS_LDFLAGS})
message(STATUS "LDFLAGS_OTHER" ${SDBUS_LDFLAGS_OTHER})
message(STATUS "INCLUDE DIRS" ${SDBUS_INCLUDE_DIRS})
message(STATUS "CFLAGS" ${SDBUS_CFLAGS})
message(STATUS "CFLAGS_OTHER" ${SDBUS_CFLAGS_OTHER})

are empty. Which leads to a linker error when compiling the project. Indeed when calling

pkg-config --libs systemd

it's empty as well. Anyone has any idea on how to solve that and why all these information is not available for systemd?

like image 747
plazmakeks Avatar asked Jun 07 '26 21:06

plazmakeks


1 Answers

You should use

pkg_check_modules(SDBUS REQUIRED libsystemd)

Note the extra 'lib' prefix.

like image 90
Carlo Wood Avatar answered Jun 10 '26 19:06

Carlo Wood