Skip to content

Commit

Permalink
cmake: add ndctl and daxctl to build pmem
Browse files Browse the repository at this point in the history
In order to enable the pmem character device, add ndct=y to the parameter
of compiling the pmem library when WITH_BLUESTORE_PMEM is ON. Because
after find_ndctl and find_daxctl are added, the dependency packages
required by WITH_BLUESTORE_PMEM and WITH_RBD_RWL become more different.
So separated these two. libpmem has no version required. libpmemobj
required version >=1.8.

Signed-off-by: Yin Congmin <congmin.yin@intel.com>
  • Loading branch information
CongMinYin committed Jun 27, 2022
1 parent d4f48f5 commit d29e407
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 16 deletions.
19 changes: 12 additions & 7 deletions cmake/modules/Buildpmem.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function(build_pmem)
function(build_pmem enable_ndctl)
include(FindMake)
find_make("MAKE_EXECUTABLE" "make_cmd")

Expand All @@ -14,6 +14,15 @@ function(build_pmem)
GIT_CONFIG advice.detachedHead=false)
endif()

set(NDCTL_ENABLE)
set(LIBPMEM_INTERFACE_LINK_LIBRARIES Threads::Threads)
if(${enable_ndctl})
list(APPEND NDCTL_ENABLE NDCTL_ENABLE=y)
list(APPEND LIBPMEM_INTERFACE_LINK_LIBRARIES ndctl::ndctl daxctl::daxctl)
else()
list(APPEND NDCTL_ENABLE NDCTL_ENABLE=n)
endif()

# Use debug PMDK libs in debug lib/rbd builds
if(CMAKE_BUILD_TYPE STREQUAL Debug)
set(PMDK_LIB_DIR "debug")
Expand All @@ -25,11 +34,7 @@ function(build_pmem)
ExternalProject_Add(pmdk_ext
${source_dir_args}
CONFIGURE_COMMAND ""
# Explicitly built w/o NDCTL, otherwise if ndtcl is present on the
# build system tests statically linking to librbd (which uses
# libpmemobj) will not link (because we don't build the ndctl
# static library here).
BUILD_COMMAND ${make_cmd} CC=${CMAKE_C_COMPILER} EXTRA_CFLAGS=-Wno-error NDCTL_ENABLE=n BUILD_EXAMPLES=n BUILD_BENCHMARKS=n DOC=n
BUILD_COMMAND ${make_cmd} CC=${CMAKE_C_COMPILER} EXTRA_CFLAGS=-Wno-error ${NDCTL_ENABLE} BUILD_EXAMPLES=n BUILD_BENCHMARKS=n DOC=n
BUILD_IN_SOURCE 1
BUILD_BYPRODUCTS "<SOURCE_DIR>/src/${PMDK_LIB_DIR}/libpmem.a" "<SOURCE_DIR>/src/${PMDK_LIB_DIR}/libpmemobj.a"
INSTALL_COMMAND "")
Expand All @@ -48,7 +53,7 @@ function(build_pmem)
set_target_properties(pmem::pmem PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${PMDK_INCLUDE}
IMPORTED_LOCATION "${PMDK_LIB}/libpmem.a"
INTERFACE_LINK_LIBRARIES Threads::Threads)
INTERFACE_LINK_LIBRARIES "${LIBPMEM_INTERFACE_LINK_LIBRARIES}")

# libpmemobj
add_library(pmem::pmemobj STATIC IMPORTED GLOBAL)
Expand Down
26 changes: 17 additions & 9 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -482,21 +482,29 @@ if(WIN32)
list(APPEND ceph_common_deps dlfcn_win32)
endif()

if(WITH_BLUESTORE_PMEM OR WITH_RBD_RWL)
if(WITH_BLUESTORE_PMEM)
find_package(ndctl 63 REQUIRED)
find_package(daxctl 63 REQUIRED)
if(WITH_SYSTEM_PMDK)
set(pmem_COMPONENTS)
if(WITH_BLUESTORE_PMEM)
list(APPEND pmem_COMPONENTS pmem)
endif()
if(WITH_RBD_RWL)
list(APPEND pmem_COMPONENTS pmemobj)
endif()
find_package(pmem 1.10 REQUIRED COMPONENTS ${pmem_COMPONENTS})
list(APPEND pmem_COMPONENTS pmem)
find_package(COMPONENTS ${pmem_COMPONENTS})
else()
include(Buildpmem)
set(enable_ndctl ON)
build_pmem(${enable_ndctl})
endif()
endif()

if(WITH_RBD_RWL)
if(WITH_SYSTEM_PMDK)
set(pmem_COMPONENTS)
list(APPEND pmem_COMPONENTS pmemobj)
find_package(pmem 1.8 REQUIRED COMPONENTS ${pmem_COMPONENTS})
else()
include(Buildpmem)
build_pmem()
set(enable_ndctl OFF)
build_pmem(${enable_ndctl})
endif()
endif()

Expand Down

0 comments on commit d29e407

Please sign in to comment.