From 574dedbb6e958cf25c13a50fc3bdc83a193046be Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Mon, 30 Dec 2019 10:11:27 +0100 Subject: build: Fix systemd service installation The systemd service installer failed on some systems because the LIBDIR is not always where systemd is installed. This adds a more robust way of finding the systemd service directory. Signed-off-by: Dimitri Staessens Signed-off-by: Sander Vrijders --- CMakeLists.txt | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index 310d9925..7ff4292e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -111,12 +111,24 @@ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ouroboros-dev.pc" install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ouroboros-irm.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") -if (IS_DIRECTORY "/usr/lib/systemd") - configure_file("${CMAKE_CURRENT_SOURCE_DIR}/irmd.service.in" - "${CMAKE_CURRENT_BINARY_DIR}/irmd.service" @ONLY) - - install(FILES "${CMAKE_CURRENT_BINARY_DIR}/irmd.service" - DESTINATION "${CMAKE_INSTALL_LIBDIR}/systemd/system") +# modified from https://github.com/ximion/limba +pkg_check_modules(SYSTEMD "systemd") +if (SYSTEMD_FOUND) + if ("${SYSTEMD_UNITDIR}" STREQUAL "") + execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} + --variable=systemdsystemunitdir systemd + OUTPUT_VARIABLE SYSTEMD_UNITDIR) + string(REGEX REPLACE "[ \t\n]+" "" SYSTEMD_UNITDIR + "${SYSTEMD_UNITDIR}" + ) + endif () + if (NOT ${SYSTEMD_UNITDIR} STREQUAL "") + message(STATUS "Installing systemd service in: ${SYSTEMD_UNITDIR}") + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/irmd.service.in" + "${CMAKE_CURRENT_BINARY_DIR}/irmd.service" @ONLY) + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/irmd.service" + DESTINATION "${SYSTEMD_UNITDIR}") + endif () endif () enable_testing() -- cgit v1.2.3