Merge pull request #14927 from thalieht/webui_translate
[qBittorrent.git] / cmake / Modules / FindSystemd.cmake
blob06bc1ec347fd48ec8697b9ae7633481925968eb3
1 #######
2 # Find systemd service dir
3 # sets variables
4 # SYSTEMD_FOUND
5 # SYSTEMD_SERVICES_INSTALL_DIR
7 find_package(PkgConfig QUIET REQUIRED)
9 if (NOT SYSTEMD_FOUND)
10     pkg_check_modules(SYSTEMD "systemd")
11 endif()
13 if (SYSTEMD_FOUND AND "${SYSTEMD_SERVICES_INSTALL_DIR}" STREQUAL "")
14     execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE}
15         --variable=systemdsystemunitdir systemd
16         OUTPUT_VARIABLE SYSTEMD_SERVICES_INSTALL_DIR)
17     string(REGEX REPLACE "[ \t\n]+" "" SYSTEMD_SERVICES_INSTALL_DIR
18         "${SYSTEMD_SERVICES_INSTALL_DIR}")
19 elseif (NOT SYSTEMD_FOUND AND SYSTEMD_SERVICES_INSTALL_DIR)
20     message (FATAL_ERROR "Variable SYSTEMD_SERVICES_INSTALL_DIR is\
21         defined, but we can't find systemd using pkg-config")
22 endif()
24 if (SYSTEMD_FOUND)
25     message(STATUS "systemd services install dir: ${SYSTEMD_SERVICES_INSTALL_DIR}")
26 endif()