1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
#[=======================================================================[.rst:
FindSystemd
-------
Finds the Systemd library.
Imported Targets
^^^^^^^^^^^^^^^^
This module provides the following imported targets, if found:
``Systemd::libsystemd``
The Systemd library
Result Variables
^^^^^^^^^^^^^^^^
This will define the following variables:
``Systemd_FOUND``
True if the system has the Systemd library.
#]=======================================================================]
# Use pkg-config if available
find_package(PkgConfig QUIET)
pkg_check_modules(PC_SYSTEMD QUIET libsystemd)
# Find the headers and library
find_path(
Systemd_INCLUDE_DIR
NAMES "systemd/sd-daemon.h"
HINTS "${PC_SYSTEMD_INCLUDEDIR}")
find_library(
Systemd_LIBRARY
NAMES "systemd"
HINTS "${PC_SYSTEMD_LIBDIR}")
# Extract additional flags if pkg-config is available
if(PC_SYSTEMD_FOUND)
get_target_properties_from_pkg_config("${Systemd_LIBRARY}" "PC_SYSTEMD"
"_systemd")
endif()
# Forward the result to CMake
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Systemd REQUIRED_VARS "Systemd_LIBRARY"
"Systemd_INCLUDE_DIR")
if(Systemd_FOUND AND NOT TARGET Systemd::libsystemd)
add_library(Systemd::libsystemd UNKNOWN IMPORTED)
set_target_properties(
Systemd::libsystemd
PROPERTIES IMPORTED_LOCATION "${Systemd_LIBRARY}"
INTERFACE_COMPILE_OPTIONS "${_systemd_compile_options}"
INTERFACE_INCLUDE_DIRECTORIES "${Systemd_INCLUDE_DIR}"
INTERFACE_LINK_LIBRARIES "${_systemd_link_libraries}"
INTERFACE_LINK_DIRECTORIES "${_systemd_link_directories}")
endif()
mark_as_advanced(Systemd_INCLUDE_DIR Systemd_LIBRARY)
|