qBittorrent/cmake/Modules/FindSystemd.cmake
Eugene Shalygin 15ef4fcc56 cmake: fix FindSystemd.cmake
Apparently, recent version of CMake made PkgConfig stuff scooped and we
need to call find_package(PkgConfig) in FindSystemd.cmake too, the call
in FindLibtorrentRasterbar.cmake, that is always used first, is not
enough now.
2017-05-19 10:44:36 +02:00

26 lines
888 B
CMake

#######
# Find systemd service dir
# sets variables
# SYSTEMD_FOUND
# SYSTEMD_SERVICES_INSTALL_DIR
find_package(PkgConfig QUIET REQUIRED)
if (NOT SYSTEMD_FOUND)
pkg_check_modules(SYSTEMD "systemd")
endif(NOT SYSTEMD_FOUND)
if (SYSTEMD_FOUND AND "${SYSTEMD_SERVICES_INSTALL_DIR}" STREQUAL "")
execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE}
--variable=systemdsystemunitdir systemd
OUTPUT_VARIABLE SYSTEMD_SERVICES_INSTALL_DIR)
string(REGEX REPLACE "[ \t\n]+" "" SYSTEMD_SERVICES_INSTALL_DIR
"${SYSTEMD_SERVICES_INSTALL_DIR}")
elseif (NOT SYSTEMD_FOUND AND SYSTEMD_SERVICES_INSTALL_DIR)
message (FATAL_ERROR "Variable SYSTEMD_SERVICES_INSTALL_DIR is\
defined, but we can't find systemd using pkg-config")
endif()
if (SYSTEMD_FOUND)
message(STATUS "systemd services install dir: ${SYSTEMD_SERVICES_INSTALL_DIR}")
endif(SYSTEMD_FOUND)