| 1 |
# Try to find the setcap binary and cap libraries |
| 2 |
# |
| 3 |
# This will define: |
| 4 |
# |
| 5 |
# Libcap_FOUND - system has the cap library and setcap binary |
| 6 |
# Libcap_LIBRARIES - cap libraries to link against |
| 7 |
# SETCAP_EXECUTABLE - path of the setcap binary |
| 8 |
# In addition, the following targets are defined: |
| 9 |
# |
| 10 |
# Libcap::SetCapabilities |
| 11 |
# |
| 12 |
|
| 13 |
|
| 14 |
# SPDX-FileCopyrightText: 2014 Hrvoje Senjan <[email protected]> |
| 15 |
# |
| 16 |
# SPDX-License-Identifier: BSD-3-Clause |
| 17 |
|
| 18 |
find_program(SETCAP_EXECUTABLE NAMES setcap DOC "The setcap executable") |
| 19 |
|
| 20 |
find_library(Libcap_LIBRARIES NAMES cap DOC "The cap (capabilities) library") |
| 21 |
|
| 22 |
include(FindPackageHandleStandardArgs) |
| 23 |
find_package_handle_standard_args(Libcap FOUND_VAR Libcap_FOUND |
| 24 |
REQUIRED_VARS SETCAP_EXECUTABLE Libcap_LIBRARIES) |
| 25 |
|
| 26 |
if(Libcap_FOUND AND NOT TARGET Libcap::SetCapabilities) |
| 27 |
add_executable(Libcap::SetCapabilities IMPORTED) |
| 28 |
set_target_properties(Libcap::SetCapabilities PROPERTIES |
| 29 |
IMPORTED_LOCATION "${SETCAP_EXECUTABLE}" |
| 30 |
) |
| 31 |
endif() |
| 32 |
|
| 33 |
mark_as_advanced(SETCAP_EXECUTABLE Libcap_LIBRARIES) |
| 34 |
|
| 35 |
include(FeatureSummary) |
| 36 |
set_package_properties(Libcap PROPERTIES |
| 37 |
URL https://sites.google.com/site/fullycapable/ |
| 38 |
DESCRIPTION "Capabilities are a measure to limit the omnipotence of the superuser.") |