blob: 3fcde4c5435a79c61c53bbd27e1932441a056d98 (
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
# SPDX-FileCopyrightText: 2021 Ahmad Samir <a.samirh78@gmail.com>
#
# SPDX-License-Identifier: BSD-3-Clause
#[=======================================================================[.rst:
FindLibMount
------------
Try to find the libmount library (part of util-linux), once done this will define:
``LibMount_FOUND``
LibMount was found on the system.
``LibMount_INCLUDE_DIRS``
The libmount include directory.
``LibMount_LIBRARIES``
The libmount libraries.
``LibMount_VERSION``
The libmount version.
If ``LibMount_FOUND`` is TRUE, it will also define the following imported target:
``LibMount::LibMount``
The libmount library
Since 5.83.0
#]=======================================================================]
find_package(PkgConfig QUIET)
pkg_check_modules(PC_LIBMOUNT QUIET mount)
find_path(LibMount_INCLUDE_DIRS NAMES libmount/libmount.h HINTS ${PC_LIBMOUNT_INCLUDE_DIRS})
find_library(LibMount_LIBRARIES NAMES mount HINTS ${PC_LIBMOUNT_LIBRARY_DIRS})
set(LibMount_VERSION ${PC_LIBMOUNT_VERSION})
if(LibMount_INCLUDE_DIRS AND NOT LibMount_VERSION)
file(READ "${LibMount_INCLUDE_DIRS}/libmount/libmount.h" _LibMount_header_contents)
string(REGEX MATCHALL "#define[ \t]+LIBMOUNT_VERSION[ \t]+\"*[0-9.]+" _LibMount_version_line "${_LibMount_header_contents}")
unset(_LibMount_header_contents)
string(REGEX REPLACE ".*LIBMOUNT_VERSION[ \t]+\"*([0-9.]+)\"*" "\\1" _version "${_LibMount_version_line}")
set(LibMount_VERSION "${_version}")
unset(_LibMount_version_line)
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LibMount
FOUND_VAR LibMount_FOUND
REQUIRED_VARS LibMount_INCLUDE_DIRS LibMount_LIBRARIES
VERSION_VAR LibMount_VERSION
)
mark_as_advanced(LibMount_INCLUDE_DIRS LibMount_LIBRARIES)
if(LibMount_FOUND AND NOT TARGET LibMount::LibMount)
add_library(LibMount::LibMount UNKNOWN IMPORTED)
set_target_properties(LibMount::LibMount PROPERTIES
IMPORTED_LOCATION "${LibMount_LIBRARIES}"
INTERFACE_INCLUDE_DIRECTORIES "${LibMount_INCLUDE_DIRS}"
INTERFACE_COMPILE_DEFINITIONS "${PC_LIBMOUNT_CFLAGS_OTHER}"
)
endif()
include(FeatureSummary)
set_package_properties(LibMount PROPERTIES
DESCRIPTION "API for getting info about mounted filesystems (part of util-linux)"
URL "https://www.kernel.org/pub/linux/utils/util-linux/"
)
|