File: FindLibcap.cmake

package info (click to toggle)
extra-cmake-modules 5.103.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 3,116 kB
  • sloc: python: 1,744; cpp: 646; ansic: 258; xml: 182; sh: 36; makefile: 5
file content (45 lines) | stat: -rw-r--r-- 1,465 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
# SPDX-FileCopyrightText: 2014 Hrvoje Senjan <hrvoje.senjan@gmail.com>
#
# SPDX-License-Identifier: BSD-3-Clause

#[=======================================================================[.rst:
FindLibcap
----------
Try to find the setcap binary and cap libraries

This will define:

``Libcap_FOUND``
    system has the cap library and setcap binary
``Libcap_LIBRARIES``
    cap libraries to link against
``SETCAP_EXECUTABLE``
    path of the setcap binary

In addition, the following targets are defined:
  ``Libcap::SetCapabilities``

Since 5.80.0
#]=======================================================================]

find_program(SETCAP_EXECUTABLE NAMES setcap DOC "The setcap executable")

find_library(Libcap_LIBRARIES NAMES cap DOC "The cap (capabilities) library")

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Libcap FOUND_VAR Libcap_FOUND
                                      REQUIRED_VARS SETCAP_EXECUTABLE Libcap_LIBRARIES)

if(Libcap_FOUND AND NOT TARGET Libcap::SetCapabilities)
    add_executable(Libcap::SetCapabilities IMPORTED)
    set_target_properties(Libcap::SetCapabilities PROPERTIES
        IMPORTED_LOCATION "${SETCAP_EXECUTABLE}"
    )
endif()

mark_as_advanced(SETCAP_EXECUTABLE Libcap_LIBRARIES)

include(FeatureSummary)
set_package_properties(Libcap PROPERTIES
    URL https://sites.google.com/site/fullycapable/
    DESCRIPTION "Capabilities are a measure to limit the omnipotence of the superuser.")