summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2012-12-24 17:14:40 +0100
committerMatthias Schiffer <mschiffer@universe-factory.net>2012-12-24 17:14:40 +0100
commiteaac49427339a365aac2d3505f567572cfbdbb96 (patch)
treeb7a8d43aa24396d513747a9eb45d9e0fd29ce232
parentcd8ab035e605c5d8f8105861b2818a54a21eb311 (diff)
downloadfastd-eaac49427339a365aac2d3505f567572cfbdbb96.tar
fastd-eaac49427339a365aac2d3505f567572cfbdbb96.zip
Add WITH_CAPABILITIES CMake flag and check for libcap
-rw-r--r--CMakeLists.txt8
-rw-r--r--FindCAP.cmake16
-rw-r--r--config.h.in2
-rw-r--r--src/CMakeLists.txt4
4 files changed, 28 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 13c0079..e2d5332 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -17,6 +17,14 @@ pkg_check_modules(UECC REQUIRED libuecc>=2)
find_package(NaCl REQUIRED)
+set(WITH_CAPABILITIES TRUE CACHE BOOL "Include support for POSIX capabilities")
+
+if(WITH_CAPABILITIES)
+ find_package(CAP REQUIRED)
+else(WITH_CAPABILITIES)
+ set(CAP_INCLUDE_DIR "")
+ set(CAP_LIBRARY "")
+endif(WITH_CAPABILITIES)
set(WITH_CRYPTO_AES128CTR_NACL TRUE CACHE BOOL "Include the AES128-CTR implementation from the NaCl library")
set(WITH_CRYPTO_AES128CTR_LINUX TRUE CACHE BOOL "Support using the AES128-CTR implementation in the Linux kernel")
diff --git a/FindCAP.cmake b/FindCAP.cmake
new file mode 100644
index 0000000..80afff3
--- /dev/null
+++ b/FindCAP.cmake
@@ -0,0 +1,16 @@
+FIND_PATH(CAP_INCLUDE_DIR sys/capability.h)
+FIND_LIBRARY(CAP_LIBRARY NAMES cap)
+
+IF (CAP_INCLUDE_DIR AND CAP_LIBRARY)
+ SET(CAP_FOUND TRUE)
+ENDIF (CAP_INCLUDE_DIR AND CAP_LIBRARY)
+
+IF (CAP_FOUND)
+ IF (NOT CAP_FIND_QUIETLY)
+ MESSAGE(STATUS "Found libcap: ${CAP_LIBRARY}; include path: ${CAP_INCLUDE_DIR}")
+ ENDIF (NOT CAP_FIND_QUIETLY)
+ELSE (CAP_FOUND)
+ IF (CAP_FIND_REQUIRED)
+ MESSAGE(FATAL_ERROR "Could not find libcap")
+ ENDIF (CAP_FIND_REQUIRED)
+ENDIF (CAP_FOUND)
diff --git a/config.h.in b/config.h.in
index fba95a8..73fb2eb 100644
--- a/config.h.in
+++ b/config.h.in
@@ -28,6 +28,8 @@
#ifndef _FASTD_CONFIG_H_
#define _FASTD_CONFIG_H_
+#cmakedefine WITH_CAPABILITIES
+
#cmakedefine USE_CRYPTO_AES128CTR
#cmakedefine USE_CRYPTO_GHASH
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 32ce8c3..0fb0ebd 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -8,7 +8,7 @@ if(WITH_METHOD_AES128_GCM)
list(APPEND METHODS method_aes128_gcm.c)
endif(WITH_METHOD_AES128_GCM)
-include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${FASTD_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${UECC_INCLUDE_DIRS} ${NACL_INCLUDE_DIR})
+include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${FASTD_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CAP_INCLUDE_DIR} ${UECC_INCLUDE_DIRS} ${NACL_INCLUDE_DIR})
link_directories(${UECC_LIBRARY_DIRS})
FLEX_TARGET(fastd_config_lex config.l ${CMAKE_CURRENT_BINARY_DIR}/config.ll.c)
@@ -32,6 +32,6 @@ add_executable(fastd
${METHODS}
)
set_target_properties(fastd PROPERTIES COMPILE_FLAGS -pthread ${UECC_CFLAGS_OTHER} LINK_FLAGS -pthread ${UECC_LDFLAGS_OTHER})
-target_link_libraries(fastd rt ${UECC_LIBRARIES} ${NACL_LIBRARY})
+target_link_libraries(fastd rt ${CAP_LIBRARY} ${UECC_LIBRARIES} ${NACL_LIBRARY})
install(TARGETS fastd RUNTIME DESTINATION bin)