From 7e1ef0c0c9db1878b68bcd1693e0897ebe6975cd Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Sat, 3 Apr 2021 21:32:36 +0800 Subject: [PATCH] cmake: require libpmem 1.7 detect the libpmem libraries' version using pkg-config please note, the version is not identical to the ones defined in libpmem.h or libpmemobj/base.h Signed-off-by: Kefu Chai --- cmake/modules/Findpmem.cmake | 13 ++++++++++++- src/CMakeLists.txt | 4 ++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/cmake/modules/Findpmem.cmake b/cmake/modules/Findpmem.cmake index 2f5366eb5406e..def31cb1ff28e 100644 --- a/cmake/modules/Findpmem.cmake +++ b/cmake/modules/Findpmem.cmake @@ -12,6 +12,16 @@ foreach(component pmem ${pmem_FIND_COMPONENTS}) if(found EQUAL -1) message(FATAL_ERROR "unknown libpmem component: ${component}") endif() + set(pkg_module_spec "lib${component}") + if(pmem_FIND_VERSION_EXACT) + set(pkg_module_spec "lib${component}=${pmem_FIND_VERSION}") + elseif(pmem_FIND_VERSION) + set(pkg_module_spec "lib${component}>=${pmem_FIND_VERSION}") + endif() + pkg_check_modules(PKG_${component} QUIET ${pkg_module_spec}) + if(NOT pmem_VERSION_STRING OR PKG_${component}_VERSION VERSION_LESS pmem_VERSION_STRING) + set(pmem_VERSION_STRING ${PKG_${component}_VERSION}) + endif() pkg_check_modules(PKG_${component} QUIET lib${component}) find_path(pmem_${component}_INCLUDE_DIR NAMES lib${component}.h @@ -28,7 +38,8 @@ endforeach() include(FindPackageHandleStandardArgs) find_package_handle_standard_args(pmem - DEFAULT_MSG pmem_INCLUDE_DIRS pmem_LIBRARIES) + REQUIRED_VARS pmem_INCLUDE_DIRS pmem_LIBRARIES + VERSION_VAR pmem_VERSION_STRING) mark_as_advanced( pmem_INCLUDE_DIRS diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 88d2d0eb5500a..db460978dd536 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -508,10 +508,10 @@ endif() if(WITH_BLUESTORE_PMEM OR WITH_RBD_RWL) if(WITH_SYSTEM_PMDK) if(WITH_BLUESTORE_PMEM) - find_package(pmem REQUIRED COMPONENTS pmem) + find_package(pmem 1.7 REQUIRED COMPONENTS pmem) endif() if(WITH_RBD_RWL) - find_package(pmem REQUIRED COMPONENTS pmemobj) + find_package(pmem 1.7 REQUIRED COMPONENTS pmemobj) endif() else() include(Buildpmem) -- 2.39.5