Changeset View
Changeset View
Standalone View
Standalone View
cmake/FindLibcap.cmake
- This file was added.
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 | # Copyright (c) 2014, Hrvoje Senjan, <hrvoje.senjan@gmail.com> | ||||
15 | # | ||||
16 | # Redistribution and use in source and binary forms, with or without | ||||
17 | # modification, are permitted provided that the following conditions | ||||
18 | # are met: | ||||
19 | # | ||||
20 | # 1. Redistributions of source code must retain the copyright | ||||
21 | # notice, this list of conditions and the following disclaimer. | ||||
22 | # 2. Redistributions in binary form must reproduce the copyright | ||||
23 | # notice, this list of conditions and the following disclaimer in the | ||||
24 | # documentation and/or other materials provided with the distribution. | ||||
25 | # 3. The name of the author may not be used to endorse or promote products | ||||
26 | # derived from this software without specific prior written permission. | ||||
27 | # | ||||
28 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||||
29 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||||
30 | # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||||
31 | # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||||
32 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||||
33 | # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||||
34 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||||
35 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||||
36 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||||
37 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||
38 | | ||||
39 | find_program(SETCAP_EXECUTABLE NAMES setcap DOC "The setcap executable") | ||||
40 | | ||||
41 | find_library(Libcap_LIBRARIES NAMES cap DOC "The cap (capabilities) library") | ||||
42 | | ||||
43 | include(FindPackageHandleStandardArgs) | ||||
44 | find_package_handle_standard_args(Libcap FOUND_VAR Libcap_FOUND | ||||
45 | REQUIRED_VARS SETCAP_EXECUTABLE Libcap_LIBRARIES) | ||||
46 | | ||||
47 | if(Libcap_FOUND AND NOT TARGET Libcap::SetCapabilities) | ||||
48 | add_executable(Libcap::SetCapabilities IMPORTED) | ||||
49 | set_target_properties(Libcap::SetCapabilities PROPERTIES | ||||
50 | IMPORTED_LOCATION "${SETCAP_EXECUTABLE}" | ||||
51 | ) | ||||
52 | endif() | ||||
53 | | ||||
54 | mark_as_advanced(SETCAP_EXECUTABLE Libcap_LIBRARIES) | ||||
55 | | ||||
56 | include(FeatureSummary) | ||||
57 | set_package_properties(Libcap PROPERTIES | ||||
58 | URL https://sites.google.com/site/fullycapable/ | ||||
59 | DESCRIPTION "Capabilities are a measure to limit the omnipotence of the superuser.") |