From b4cc9a9aa83fd9315d7b313ef39b695662b52475 Mon Sep 17 00:00:00 2001 From: Jianpeng Ma Date: Fri, 20 Oct 2017 00:44:09 +0800 Subject: [PATCH] cmake: Build libpmem from source code. Signed-off-by: Jianpeng Ma --- CMakeLists.txt | 7 +++---- cmake/modules/Findpmem.cmake | 15 --------------- src/os/CMakeLists.txt | 29 +++++++++++++++++++++++++---- src/os/bluestore/BlockDevice.cc | 2 +- src/os/bluestore/PMEMDevice.cc | 2 +- 5 files changed, 30 insertions(+), 25 deletions(-) delete mode 100644 cmake/modules/Findpmem.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 9ff17a8f754f7..b69aeb34e81b4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -226,10 +226,9 @@ if(WITH_SPDK) endif(WITH_SPDK) option(WITH_PMEM "Enable PMEM" OFF) -if(WITH_PMEM) - find_package(pmem REQUIRED) - set(HAVE_PMEM ${PMEM_FOUND}) -endif(WITH_PMEM) +if (WITH_PMEM) + set(HAVE_PMEM ON) +endif() option(WITH_BLUEFS "libbluefs library" OFF) diff --git a/cmake/modules/Findpmem.cmake b/cmake/modules/Findpmem.cmake deleted file mode 100644 index efcf6828898a1..0000000000000 --- a/cmake/modules/Findpmem.cmake +++ /dev/null @@ -1,15 +0,0 @@ -# Try to find libpmem -# -# Once done, this will define -# -# PMEM_FOUND -# PMEM_INCLUDE_DIR -# PMEM_LIBRARY - -find_path(PMEM_INCLUDE_DIR NAMES libpmem.h) -find_library(PMEM_LIBRARY NAMES pmem) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(pmem DEFAULT_MSG PMEM_LIBRARY PMEM_INCLUDE_DIR) - -mark_as_advanced(PMEM_INCLUDE_DIR PMEM_LIBRARY) diff --git a/src/os/CMakeLists.txt b/src/os/CMakeLists.txt index ad2940449ac20..1e1a1a84cb51a 100644 --- a/src/os/CMakeLists.txt +++ b/src/os/CMakeLists.txt @@ -85,10 +85,6 @@ if(WITH_FUSE) target_link_libraries(os ${FUSE_LIBRARIES}) endif() -if(WITH_PMEM) - target_link_libraries(os ${PMEM_LIBRARY}) -endif() - if(HAVE_LIBZFS) target_link_libraries(os ${ZFS_LIBRARIES}) endif() @@ -141,6 +137,31 @@ if(WITH_SPDK) endforeach() endif(WITH_SPDK) +if(WITH_PMEM) + include(ExternalProject) + ExternalProject_Add(nvml_ext + DOWNLOAD_DIR ${CMAKE_BINARY_DIR}/src/ + GIT_REPOSITORY "https://github.com/ceph/nvml.git" + GIT_TAG "dd5b62dbc2cbbe048087dea" + SOURCE_DIR ${CMAKE_BINARY_DIR}/src/nvml + CONFIGURE_COMMAND "" + BUILD_COMMAND $(MAKE) + BUILD_IN_SOURCE 1 + INSTALL_COMMAND "true") + + ExternalProject_Add_Step(nvml_ext forcebuild + DEPENDEES configure + DEPENDERS build + COMMAND "true" + ALWAYS 1) + add_library(pmem STATIC IMPORTED GLOBAL) + add_dependencies(pmem nvml_ext) + set_target_properties(pmem PROPERTIES + IMPORTED_LOCATION "${CMAKE_BINARY_DIR}/src/nvml/src/nondebug/libpmem.a") + target_link_libraries(os pmem) + target_include_directories(os PRIVATE "${CMAKE_BINARY_DIR}/src/nvml/src/include") +endif(WITH_PMEM) + if(WITH_LTTNG AND WITH_EVENTTRACE) add_dependencies(os eventtrace_tp) endif() diff --git a/src/os/bluestore/BlockDevice.cc b/src/os/bluestore/BlockDevice.cc index ca81952290e02..b6f4dd8a10303 100644 --- a/src/os/bluestore/BlockDevice.cc +++ b/src/os/bluestore/BlockDevice.cc @@ -24,7 +24,7 @@ #if defined(HAVE_PMEM) #include "PMEMDevice.h" -#include +#include "libpmem.h" #endif #include "common/debug.h" diff --git a/src/os/bluestore/PMEMDevice.cc b/src/os/bluestore/PMEMDevice.cc index 41201e07ef7c9..11f66706a9c34 100644 --- a/src/os/bluestore/PMEMDevice.cc +++ b/src/os/bluestore/PMEMDevice.cc @@ -18,9 +18,9 @@ #include #include #include -#include #include "PMEMDevice.h" +#include "libpmem.h" #include "include/types.h" #include "include/compat.h" #include "include/stringify.h" -- 2.39.5