diff options
author | Nicolas Fella <nicolas.fella@gmx.de> | 2021-02-10 14:09:01 +0100 |
---|---|---|
committer | Nicolas Fella <nicolas.fella@gmx.de> | 2021-02-10 14:09:01 +0100 |
commit | 9d23e2943754afab9741c47ae135037498ad9d34 (patch) | |
tree | e64b64bcf42a9403c2b844c4e0feeaa9d1682168 /find-modules | |
parent | fe91d86bf612ed0a9c1fc6cb049d123f4a416312 (diff) | |
download | extra-cmake-modules-9d23e2943754afab9741c47ae135037498ad9d34.tar.gz extra-cmake-modules-9d23e2943754afab9741c47ae135037498ad9d34.tar.bz2 |
Add FindLibcap.cmake
We have identical copies of this in kinit, kwin, ksysguard and
powerdevil. This makes it a natural candidate for inclusion in ECM.
Diffstat (limited to 'find-modules')
-rw-r--r-- | find-modules/FindLibcap.cmake | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/find-modules/FindLibcap.cmake b/find-modules/FindLibcap.cmake new file mode 100644 index 00000000..a9fc2112 --- /dev/null +++ b/find-modules/FindLibcap.cmake @@ -0,0 +1,44 @@ +#.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 +# +#===================================================================== +# SPDX-FileCopyrightText: 2014 Hrvoje Senjan <hrvoje.senjan@gmail.com> +# +# SPDX-License-Identifier: BSD-3-Clause +#===================================================================== + +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.") |