From d29e407cf8e443c13ee918fd1511b330e45672a3 Mon Sep 17 00:00:00 2001 From: Yin Congmin Date: Sat, 25 Jun 2022 00:11:18 +0800 Subject: [PATCH] cmake: add ndctl and daxctl to build pmem 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 --- cmake/modules/Buildpmem.cmake | 19 ++++++++++++------- src/CMakeLists.txt | 26 +++++++++++++++++--------- 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/cmake/modules/Buildpmem.cmake b/cmake/modules/Buildpmem.cmake index e264fabd5d2a6a..08cf29b685097e 100644 --- a/cmake/modules/Buildpmem.cmake +++ b/cmake/modules/Buildpmem.cmake @@ -1,4 +1,4 @@ -function(build_pmem) +function(build_pmem enable_ndctl) include(FindMake) find_make("MAKE_EXECUTABLE" "make_cmd") @@ -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") @@ -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 "/src/${PMDK_LIB_DIR}/libpmem.a" "/src/${PMDK_LIB_DIR}/libpmemobj.a" INSTALL_COMMAND "") @@ -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) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e78fb5725dcc5b..6a45e06137fdb6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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()