summaryrefslogtreecommitdiffstats
path: root/CMake
diff options
context:
space:
mode:
authorLibravatar JerziKaminsky <JerziKaminsky@users.noreply.github.com>2017-04-06 02:42:25 +0300
committerLibravatar Jerzi Kaminsky <JerziKaminsky@users.noreply.github.com>2017-04-07 03:14:16 +0300
commitaa6bd85da147291728acb0828f5c987a02a66193 (patch)
treed160212842d3e6bdf00f5fa2f958db732defefec /CMake
parentMerge pull request #1151 from ascent12/master (diff)
downloadsway-aa6bd85da147291728acb0828f5c987a02a66193.tar.gz
sway-aa6bd85da147291728acb0828f5c987a02a66193.tar.zst
sway-aa6bd85da147291728acb0828f5c987a02a66193.zip
Add libcap check to CMake
- Moved ``<sys/capability.h>`` include inside `__linux__` guard, because all uses are similarly guarded. - <sys/capability.h> is part of an optional devel package, at least in fedora. CMake now explicitly checks that libcap devel files are available. - Added libcap to the list of install packages in .travis.yml, to make the dependency explicit. travis-ci installs the package by default, which is why this hasn't surfaced previously.
Diffstat (limited to 'CMake')
-rw-r--r--CMake/FindLibcap.cmake56
1 files changed, 56 insertions, 0 deletions
diff --git a/CMake/FindLibcap.cmake b/CMake/FindLibcap.cmake
new file mode 100644
index 00000000..b34e5e37
--- /dev/null
+++ b/CMake/FindLibcap.cmake
@@ -0,0 +1,56 @@
1#.rst:
2# FindLibcap
3# -------
4#
5# Find Libcap library
6#
7# Try to find Libcap library. The following values are defined
8#
9# ::
10#
11# Libcap_FOUND - True if Libcap is available
12# Libcap_INCLUDE_DIRS - Include directories for Libcap
13# Libcap_LIBRARIES - List of libraries for Libcap
14# Libcap_DEFINITIONS - List of definitions for Libcap
15#
16# and also the following more fine grained variables
17#
18# ::
19#
20# Libcap_VERSION
21# Libcap_VERSION_MAJOR
22# Libcap_VERSION_MINOR
23#
24#=============================================================================
25# Copyright (c) 2017 Jerzi Kaminsky
26#
27# Distributed under the OSI-approved BSD License (the "License");
28#
29# This software is distributed WITHOUT ANY WARRANTY; without even the
30# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
31# See the License for more information.
32#=============================================================================
33
34include(FeatureSummary)
35set_package_properties(Libcap PROPERTIES
36 URL "https://www.kernel.org/pub/linux/libs/security/linux-privs/libcap2"
37 DESCRIPTION "Library for getting and setting POSIX.1e capabilities")
38
39find_package(PkgConfig)
40pkg_check_modules(PC_CAP QUIET Libcap)
41find_library(Libcap_LIBRARIES NAMES cap HINTS ${PC_CAP_LIBRARY_DIRS})
42find_path(Libcap_INCLUDE_DIRS sys/capability.h HINTS ${PC_CAP_INCLUDE_DIRS})
43
44set(Libcap_VERSION ${PC_CAP_VERSION})
45string(REPLACE "." ";" VERSION_LIST "${PC_CAP_VERSION}")
46
47LIST(LENGTH VERSION_LIST n)
48if (n EQUAL 2)
49 list(GET VERSION_LIST 0 Libcap_VERSION_MAJOR)
50 list(GET VERSION_LIST 1 Libcap_VERSION_MINOR)
51endif ()
52
53include(FindPackageHandleStandardArgs)
54find_package_handle_standard_args(Libcap DEFAULT_MSG Libcap_INCLUDE_DIRS Libcap_LIBRARIES)
55mark_as_advanced(Libcap_INCLUDE_DIRS Libcap_LIBRARIES Libcap_DEFINITIONS
56 Libcap_VERSION Libcap_VERSION_MAJOR Libcap_VERSION_MICRO Libcap_VERSION_MINOR)