Skip to content

Commit 6c275ab

Browse files
authored
Merge pull request ceph#55529 from tchaikov/cmake-cap
cmake: find_package(cap) before linking against it Reviewed-by: Casey Bodley <[email protected]>
2 parents ce8c2f3 + 0de5755 commit 6c275ab

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

cmake/modules/Findcap.cmake

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Try to find libcap
2+
#
3+
find_package(PkgConfig QUIET REQUIRED)
4+
5+
pkg_check_modules(PC_cap QUIET cap)
6+
7+
find_library(cap_LIBRARY
8+
NAMES cap
9+
HINTS
10+
${PC_cap_LIBDIR}
11+
${PC_cap_LIBRARY_DIRS})
12+
13+
find_path(cap_INCLUDE_DIR
14+
NAMES sys/capability.h
15+
HINTS
16+
${PC_cap_INCLUDEDIR}
17+
${PC_cap_INCLUDE_DIRS})
18+
19+
mark_as_advanced(
20+
cap_LIBRARY
21+
cap_INCLUDE_DIR)
22+
23+
include (FindPackageHandleStandardArgs)
24+
find_package_handle_standard_args (cap
25+
REQUIRED_VARS
26+
cap_LIBRARY
27+
cap_INCLUDE_DIR)
28+
29+
if(cap_FOUND AND NOT TARGET cap::cap)
30+
add_library(cap::cap UNKNOWN IMPORTED)
31+
set_target_properties(cap::cap
32+
PROPERTIES
33+
IMPORTED_LOCATION ${cap_LIBRARY}
34+
INTERFACE_INCLUDE_DIRECTORIES ${cap_INCLUDE_DIR})
35+
endif()

src/extblkdev/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ add_subdirectory(vdo)
77
add_library(extblkdev STATIC ExtBlkDevPlugin.cc)
88

99
if(NOT WIN32)
10+
find_package(cap)
1011
target_link_libraries(extblkdev cap)
1112
endif()
1213

0 commit comments

Comments
 (0)