File: FindSystemd.cmake

package info (click to toggle)
fluidsynth 2.4.4%2Bdfsg-1%2Bdeb13u1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,328 kB
  • sloc: ansic: 43,529; cpp: 1,434; xml: 1,020; makefile: 71; sh: 46
file content (62 lines) | stat: -rw-r--r-- 1,804 bytes parent folder | download | duplicates (2)
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)