]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cmake: compile libzfs backend conditionally 15907/head
authorKefu Chai <kchai@redhat.com>
Mon, 26 Jun 2017 03:58:28 +0000 (11:58 +0800)
committerKefu Chai <kchai@redhat.com>
Tue, 27 Jun 2017 15:28:03 +0000 (23:28 +0800)
* do not REQUIRE libzfs if it is enabled, this follows the way how we
  handle `WITH_XFS` option.
* also refactor the cmake script related to libxfs backend support a
  little bit.

Signed-off-by: Kefu Chai <kchai@redhat.com>
CMakeLists.txt
cmake/modules/Findxfs.cmake
cmake/modules/Findzfs.cmake [new file with mode: 0644]
src/os/CMakeLists.txt

index 8f0dab6f82d95e433da98588112386fc1a03c8a5..4903fbe945b57541547a8c936be88cc57f8f7a5c 100644 (file)
@@ -214,10 +214,16 @@ set(HAVE_LIBFUSE ${FUSE_FOUND})
 endif(${WITH_FUSE})
 
 option(WITH_XFS "XFS is here" ON)
-if(${WITH_XFS})
-find_package(xfs)
-set(HAVE_LIBXFS ${XFS_FOUND})
-endif(${WITH_XFS})
+if(WITH_XFS)
+  find_package(xfs)
+  set(HAVE_LIBXFS ${XFS_FOUND})
+endif()
+
+option(WITH_ZFS "enable LibZFS if found" OFF)
+if(WITH_ZFS)
+  find_package(zfs)
+  set(HAVE_LIBZFS ${ZFS_FOUND})
+endif()
 
 option(WITH_SPDK "Enable SPDK" OFF)
 if(WITH_SPDK)
@@ -463,7 +469,6 @@ if(${HAVE_BABELTRACE})
 endif(${HAVE_BABELTRACE})
 
 option(DEBUG_GATHER "C_Gather debugging is enabled" ON)
-option(HAVE_LIBZFS "LibZFS is enabled" OFF)
 option(ENABLE_COVERAGE "Coverage is enabled" OFF)
 option(PG_DEBUG_REFS "PG Ref debugging is enabled" OFF)
 
index ecbf91c059787c28dfdf6f717b5aafa0c5a71dd6..6171e32895e9c4ed33e62fbac7ca5dd690415133 100644 (file)
@@ -1,9 +1,9 @@
 # Try to find xfs
 # Once done, this will define
 #
-# XFS_FOUND - system has Profiler
-# XFS_INCLUDE_DIR - the Profiler include directories
-# XFS_LIBRARIES - link these to use Profiler
+# XFS_FOUND - system has libxfs
+# XFS_INCLUDE_DIR - the libxfs include directories
+# XFS_LIBRARIES - link these to use libxfs
 
 if(XFS_INCLUDE_DIR AND XFS_LIBRARIES)
        set(XFS_FIND_QUIETLY TRUE)
diff --git a/cmake/modules/Findzfs.cmake b/cmake/modules/Findzfs.cmake
new file mode 100644 (file)
index 0000000..d92dd1f
--- /dev/null
@@ -0,0 +1,28 @@
+# find libzfs or libzfslinux
+# Once done, this will define
+#
+# ZFS_FOUND - system has libzfs
+# ZFS_INCLUDE_DIR - the libzfs include directories
+# ZFS_LIBRARIES - link these to use libzfs
+
+find_package(PkgConfig)
+if(PKG_CONFIG_FOUND)
+  pkg_check_modules(ZFS QUIET libzfs)
+else()
+  find_path(ZFS_INCLUDE_DIR libzfs.h
+    HINTS
+      ENV ZFS_DIR
+    PATH_SUFFIXES libzfs)
+
+  find_library(ZFS_LIBRARIES
+    NAMES zfs
+    HINTS
+      ENV ZFS_DIR)
+  set(XFS_LIBRARIES ${LIBXFS})
+endif()
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(zfs DEFAULT_MSG
+  ZFS_INCLUDE_DIRS ZFS_LIBRARIES)
+
+mark_as_advanced(ZFS_INCLUDE_DIRS XFS_LIBRARIES)
index feda6a23bc1fb279b5336c50f668833c4898514b..5edbb2db96a8c9ded0a1e2e8619425ccb4960d7a 100644 (file)
@@ -1,9 +1,3 @@
-if(HAVE_LIBXFS)
-  set(libos_xfs_srcs
-    filestore/XfsFileStoreBackend.cc
-    fs/XFS.cc)
-endif(HAVE_LIBXFS)
-
 set(libos_srcs
   ObjectStore.cc
   Transaction.cc
@@ -19,13 +13,11 @@ set(libos_srcs
   filestore/IndexManager.cc
   filestore/LFNIndex.cc
   filestore/WBThrottle.cc
-  filestore/ZFSFileStoreBackend.cc
   memstore/MemStore.cc
   kstore/KStore.cc
   kstore/kstore_types.cc
   fs/FS.cc
-  fs/aio.cc
-  ${libos_xfs_srcs})
+  fs/aio.cc)
 
 if(HAVE_LIBAIO)
   list(APPEND libos_srcs
@@ -55,6 +47,21 @@ if(WITH_PMEM)
     bluestore/PMEMDevice.cc)
 endif(WITH_PMEM)
 
+if(HAVE_LIBXFS)
+  list(APPEND libos_srcs
+    filestore/XfsFileStoreBackend.cc
+    fs/XFS.cc)
+endif()
+
+if(HAVE_LIBZFS)
+  add_library(os_zfs_objs OBJECT
+    filestore/ZFSFileStoreBackend.cc
+    fs/ZFS.cc)
+  target_include_directories(os_zfs_objs PRIVATE
+    ${ZFS_INCLUDE_DIRS})
+  list(APPEND libos_srcs $<TARGET_OBJECTS:os_zfs_objs>)
+endif()
+
 if(WITH_SPDK)
   list(APPEND libos_srcs
     bluestore/NVMEDevice.cc)
@@ -76,6 +83,10 @@ if(WITH_PMEM)
   target_link_libraries(os ${PMEM_LIBRARY})
 endif()
 
+if(HAVE_LIBZFS)
+  target_link_libraries(os ${ZFS_LIBRARIES})
+endif()
+
 if(WITH_SPDK)
   target_link_libraries(os
     ${SPDK_LIBRARIES}