]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cmake: require libpmem 1.7
authorKefu Chai <kchai@redhat.com>
Sat, 3 Apr 2021 13:32:36 +0000 (21:32 +0800)
committerKefu Chai <kchai@redhat.com>
Sat, 3 Apr 2021 15:59:32 +0000 (23:59 +0800)
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 <kchai@redhat.com>
cmake/modules/Findpmem.cmake
src/CMakeLists.txt

index 2f5366eb5406e6ed4e5a1511935897ee8c222b3b..def31cb1ff28e1456957f25330e5cbcc072c93d5 100644 (file)
@@ -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
index 88d2d0eb5500a86c4f08e6ed23e2971f9912a170..db460978dd536053862f262ef65726d0338fd122 100644 (file)
@@ -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)