summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri@ouroboros.rocks>2019-12-30 10:11:27 +0100
committerSander Vrijders <sander@ouroboros.rocks>2020-01-02 14:08:16 +0100
commit574dedbb6e958cf25c13a50fc3bdc83a193046be (patch)
tree389bd3ec25c30da3d14d9c9b6288941636f52d86
parente87a839c128b30651a354693d7dd40ce9fa3921f (diff)
downloadouroboros-574dedbb6e958cf25c13a50fc3bdc83a193046be.tar.gz
ouroboros-574dedbb6e958cf25c13a50fc3bdc83a193046be.zip
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 <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
-rw-r--r--CMakeLists.txt24
1 files changed, 18 insertions, 6 deletions
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()