From 3e15ca3602ca6a16995f79a9857fdc12ad69286b Mon Sep 17 00:00:00 2001 From: Adam Moody Date: Wed, 29 Dec 2021 17:31:29 -0800 Subject: [PATCH] cmake check for libattr Signed-off-by: Adam Moody --- CMakeLists.txt | 7 +++++++ cmake/FindLibAttr.cmake | 25 +++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 cmake/FindLibAttr.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index dc934b09..6ec7a78d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,6 +15,13 @@ LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") OPTION(ENABLE_XATTRS "Enable code for extended attributes" ON) IF(ENABLE_XATTRS) ADD_DEFINITIONS(-DDCOPY_USE_XATTRS) + + FIND_PACKAGE(LibAttr REQUIRED) + IF(LibAttr_FOUND) + ADD_DEFINITIONS(-DHAVE_LIBATTR) + INCLUDE_DIRECTORIES(${LibAttr_INCLUDE_DIRS}) + LIST(APPEND MFU_EXTERNAL_LIBS ${LibAttr_LIBRARIES}) + ENDIF(LibAttr_FOUND) ENDIF(ENABLE_XATTRS) OPTION(ENABLE_LUSTRE "Enable optimization and features for Lustre" OFF) diff --git a/cmake/FindLibAttr.cmake b/cmake/FindLibAttr.cmake new file mode 100644 index 00000000..b5ca36b0 --- /dev/null +++ b/cmake/FindLibAttr.cmake @@ -0,0 +1,25 @@ +# - Try to find libattr +# Once done this will define +# LibAttr_FOUND - System has libattr +# LibAttr_INCLUDE_DIRS - The libattr include directories +# LibAttr_LIBRARIES - The libraries needed to use libattr + +FIND_LIBRARY(LibAttr_LIBRARIES + NAMES attr +) + +FIND_PATH(LibAttr_INCLUDE_DIRS + NAMES attr/libattr.h +) + +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibAttr DEFAULT_MSG + LibAttr_LIBRARIES + LibAttr_INCLUDE_DIRS +) + +# Hide these vars from ccmake GUI +MARK_AS_ADVANCED( + LibAttr_LIBRARIES + LibAttr_INCLUDE_DIRS +)