aboutsummaryrefslogtreecommitdiff
path: root/CMake/FindLibcap.cmake
blob: b34e5e373b120ed0e22e5368c6ad1b16f3a25b44 (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
#.rst:
# FindLibcap
# -------
#
# Find Libcap library
#
# Try to find Libcap library. The following values are defined
#
# ::
#
#   Libcap_FOUND         - True if Libcap is available
#   Libcap_INCLUDE_DIRS  - Include directories for Libcap
#   Libcap_LIBRARIES     - List of libraries for Libcap
#   Libcap_DEFINITIONS   - List of definitions for Libcap
#
# and also the following more fine grained variables
#
# ::
#
#   Libcap_VERSION
#   Libcap_VERSION_MAJOR
#   Libcap_VERSION_MINOR
#
#=============================================================================
# Copyright (c) 2017 Jerzi Kaminsky
#
# Distributed under the OSI-approved BSD License (the "License");
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================

include(FeatureSummary)
set_package_properties(Libcap PROPERTIES
   URL "https://www.kernel.org/pub/linux/libs/security/linux-privs/libcap2"
   DESCRIPTION "Library for getting and setting POSIX.1e capabilities")

find_package(PkgConfig)
pkg_check_modules(PC_CAP QUIET Libcap)
find_library(Libcap_LIBRARIES NAMES cap HINTS ${PC_CAP_LIBRARY_DIRS})
find_path(Libcap_INCLUDE_DIRS sys/capability.h HINTS ${PC_CAP_INCLUDE_DIRS})

set(Libcap_VERSION ${PC_CAP_VERSION})
string(REPLACE "." ";" VERSION_LIST "${PC_CAP_VERSION}")

LIST(LENGTH VERSION_LIST n)
if (n EQUAL 2)
   list(GET VERSION_LIST 0 Libcap_VERSION_MAJOR)
   list(GET VERSION_LIST 1 Libcap_VERSION_MINOR)
endif ()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Libcap DEFAULT_MSG Libcap_INCLUDE_DIRS Libcap_LIBRARIES)
mark_as_advanced(Libcap_INCLUDE_DIRS Libcap_LIBRARIES Libcap_DEFINITIONS
   Libcap_VERSION Libcap_VERSION_MAJOR Libcap_VERSION_MICRO Libcap_VERSION_MINOR)