summaryrefslogtreecommitdiffstats
path: root/cmake/Findlibsystemd.cmake
blob: ee00c782c804ad8f53720b5ed8bed4a24c25095e (plain)
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
# Module defines
#  LIBSYSTEMD_FOUND - libsystemd libraries and includes found
#  LIBSYSTEMD_INCLUDE_DIRS - the libsystemd include directories
#  LIBSYSTEMD_LIBRARIES - the libsystemd libraries
#
# Cache entries:
#   LIBSYSTEMD_LIBRARY      - detected libsystemd library
#   LIBSYSTEMD_INCLUDE_DIR   - detected libsystemd include dir(s)
#

if(LIBSYSTEMD_INCLUDE_DIR AND LIBSYSTEMD_LIBRARY)
    # in cache already
    set(LIBSYSTEMD_FOUND TRUE)
    set(LIBSYSTEMD_LIBRARIES ${LIBSYSTEMD_LIBRARY})
    set(LIBSYSTEMD_INCLUDE_DIRS ${LIBSYSTEMD_INCLUDE_DIR})
else()

    find_package(PkgConfig)
	if(PKG_CONFIG_FOUND)
		pkg_check_modules(_LIBSYSTEMD_PC QUIET "libsystemd")
	endif(PKG_CONFIG_FOUND)

	find_path(LIBSYSTEMD_INCLUDE_DIR systemd/sd-journal.h
			${_LIBSYSTEMD_PC_INCLUDE_DIRS}
			/usr/include
			/usr/local/include
	)
	mark_as_advanced(LIBSYSTEMD_INCLUDE_DIR)

	find_library (LIBSYSTEMD_LIBRARY NAMES systemd
			PATHS
			${_LIBSYSTEMD_PC_LIBDIR}
    )
    mark_as_advanced(LIBSYSTEMD_LIBRARY)

    include(FindPackageHandleStandardArgs)
    FIND_PACKAGE_HANDLE_STANDARD_ARGS(libsystemd DEFAULT_MSG LIBSYSTEMD_LIBRARY LIBSYSTEMD_INCLUDE_DIR)

    if(libsystemd_FOUND)
        set(LIBSYSTEMD_LIBRARIES ${LIBSYSTEMD_LIBRARY})
        set(LIBSYSTEMD_INCLUDE_DIRS ${LIBSYSTEMD_INCLUDE_DIR})
    endif()

endif()