|
22 | 22 | # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
23 | 23 |
|
24 | 24 | #[=======================================================================[.rst: |
25 | | -FindSystemd |
| 25 | +FindJournald |
26 | 26 | ----------- |
27 | 27 |
|
28 | | -Find Systemd headers and libraries. |
| 28 | +Find Journald-compatible headers and libraries. |
29 | 29 |
|
30 | 30 | Imported Targets |
31 | 31 | ^^^^^^^^^^^^^^^^ |
32 | 32 |
|
33 | | -``Systemd::Systemd`` |
34 | | - The Systemd library, if found. |
| 33 | +``Journald::Journald`` |
| 34 | + The library where Journald symbols reside, if found. |
35 | 35 |
|
36 | 36 | Result Variables |
37 | 37 | ^^^^^^^^^^^^^^^^ |
38 | 38 |
|
39 | 39 | This will define the following variables in your project: |
40 | 40 |
|
41 | | -``Systemd_FOUND`` |
42 | | - true if (the requested version of) Systemd is available. |
43 | | -``Systemd_VERSION`` |
44 | | - the version of Systemd. |
45 | | -``Systemd_LIBRARIES`` |
46 | | - the libraries to link against to use Systemd. |
47 | | -``Systemd_INCLUDE_DIRS`` |
48 | | - where to find the Systemd headers. |
49 | | -``Systemd_COMPILE_OPTIONS`` |
| 41 | +``Journald_FOUND`` |
| 42 | + true if (the requested version of) Journald is available. |
| 43 | +``Journald_VERSION`` |
| 44 | + the version of the library where Journald symbols reside. |
| 45 | +``Journald_LIBRARIES`` |
| 46 | + the libraries to link against to use Journald. |
| 47 | +``Journald_INCLUDE_DIRS`` |
| 48 | + where to find the Journald headers. |
| 49 | +``Journald_COMPILE_OPTIONS`` |
50 | 50 | this should be passed to target_compile_options(), if the |
51 | 51 | target is not used for linking |
52 | 52 |
|
53 | 53 | #]=======================================================================] |
54 | | - |
55 | 54 | find_package(PkgConfig QUIET) |
56 | 55 |
|
| 56 | +# libelogind provides compatible pc and header files |
57 | 57 | pkg_check_modules(PC_SYSTEMD QUIET libsystemd) |
58 | | -set(Systemd_COMPILE_OPTIONS ${PC_SYSTEMD_CFLAGS_OTHER}) |
59 | | -set(Systemd_VERSION ${PC_SYSTEMD_VERSION}) |
| 58 | +set(Journald_COMPILE_OPTIONS ${PC_SYSTEMD_CFLAGS_OTHER}) |
| 59 | +set(Journald_VERSION ${PC_SYSTEMD_VERSION}) |
60 | 60 |
|
61 | | -find_path(Systemd_INCLUDE_DIR |
| 61 | +find_path(Journald_INCLUDE_DIR |
62 | 62 | NAMES systemd/sd-journal.h |
63 | 63 | HINTS ${PC_SYSTEMD_INCLUDEDIR} ${PC_SYSTEMD_INCLUDE_DIRS} |
64 | 64 | ) |
65 | 65 |
|
66 | | -find_library(Systemd_LIBRARY |
67 | | - NAMES ${Systemd_NAMES} systemd |
| 66 | +find_library(Journald_LIBRARY |
| 67 | + NAMES ${Journald_NAMES} systemd |
68 | 68 | HINTS ${PC_SYSTEMD_LIBDIR} ${PC_SYSTEMD_LIBRARY_DIRS} |
69 | 69 | ) |
70 | 70 |
|
| 71 | +if (NOT Journald_LIBRARY) |
| 72 | + find_library(Journald_LIBRARY |
| 73 | + NAMES ${Journald_NAMES} elogind |
| 74 | + HINTS ${PC_SYSTEMD_LIBDIR} ${PC_SYSTEMD_LIBRARY_DIRS} |
| 75 | + ) |
| 76 | +endif () |
| 77 | + |
71 | 78 | include(FindPackageHandleStandardArgs) |
72 | | -find_package_handle_standard_args(Systemd |
73 | | - FOUND_VAR Systemd_FOUND |
74 | | - REQUIRED_VARS Systemd_LIBRARY Systemd_INCLUDE_DIR |
75 | | - VERSION_VAR Systemd_VERSION |
| 79 | +find_package_handle_standard_args(Journald |
| 80 | + FOUND_VAR Journald_FOUND |
| 81 | + REQUIRED_VARS Journald_LIBRARY Journald_INCLUDE_DIR |
| 82 | + VERSION_VAR Journald_VERSION |
76 | 83 | ) |
77 | 84 |
|
78 | | -if (Systemd_LIBRARY AND NOT TARGET Systemd::Systemd) |
79 | | - add_library(Systemd::Systemd UNKNOWN IMPORTED GLOBAL) |
80 | | - set_target_properties(Systemd::Systemd PROPERTIES |
81 | | - IMPORTED_LOCATION "${Systemd_LIBRARY}" |
82 | | - INTERFACE_COMPILE_OPTIONS "${Systemd_COMPILE_OPTIONS}" |
83 | | - INTERFACE_INCLUDE_DIRECTORIES "${Systemd_INCLUDE_DIR}" |
| 85 | +if (Journald_LIBRARY AND NOT TARGET Journald::Journald) |
| 86 | + add_library(Journald::Journald UNKNOWN IMPORTED GLOBAL) |
| 87 | + set_target_properties(Journald::Journald PROPERTIES |
| 88 | + IMPORTED_LOCATION "${Journald_LIBRARY}" |
| 89 | + INTERFACE_COMPILE_OPTIONS "${Journald_COMPILE_OPTIONS}" |
| 90 | + INTERFACE_INCLUDE_DIRECTORIES "${Journald_INCLUDE_DIR}" |
84 | 91 | ) |
85 | 92 | endif () |
86 | 93 |
|
87 | | -mark_as_advanced(Systemd_INCLUDE_DIR Systemd_LIBRARY) |
| 94 | +mark_as_advanced(Journald_INCLUDE_DIR Journald_LIBRARY) |
88 | 95 |
|
89 | | -if (Systemd_FOUND) |
90 | | - set(Systemd_LIBRARIES ${Systemd_LIBRARY}) |
91 | | - set(Systemd_INCLUDE_DIRS ${Systemd_INCLUDE_DIR}) |
| 96 | +if (Journald_FOUND) |
| 97 | + set(Journald_LIBRARIES ${Journald_LIBRARY}) |
| 98 | + set(Journald_INCLUDE_DIRS ${Journald_INCLUDE_DIR}) |
92 | 99 | endif () |
0 commit comments