]> git.proxmox.com Git - ceph.git/blobdiff - ceph/cmake/modules/Findpmem.cmake
import quincy beta 17.1.0
[ceph.git] / ceph / cmake / modules / Findpmem.cmake
index 9c8e21b918877ca88e39a6fbe208bf6754ea09e7..6f0a03ad5dda9c19a36630402371636155fa35ad 100644 (file)
@@ -4,14 +4,16 @@
 # pmem_LIBRARIES - List of libraries when using libpmem.
 # pmem_FOUND - True if pmem found.
 
-foreach(component pmem ${pmem_FIND_COMPONENTS})
-  if(component STREQUAL pmem)
-    find_path(pmem_${component}_INCLUDE_DIR libpmem.h)
-    find_library(pmem_${component}_LIBRARY pmem)
-  elseif(component STREQUAL pmemobj)
-    find_path(pmem_${component}_INCLUDE_DIR libpmemobj.h)
-    find_library(pmem_${component}_LIBRARY pmemobj)
-  else()
+find_package(PkgConfig QUIET REQUIRED)
+
+# all pmem libraries depend on pmem, so always find it
+set(pmem_FIND_COMPONENTS ${pmem_FIND_COMPONENTS} pmem)
+list(REMOVE_DUPLICATES pmem_FIND_COMPONENTS)
+
+foreach(component ${pmem_FIND_COMPONENTS})
+  set(pmem_COMPONENTS pmem pmemobj)
+  list(FIND pmem_COMPONENTS "${component}" found)
+  if(found EQUAL -1)
     message(FATAL_ERROR "unknown libpmem component: ${component}")
   endif()
   pkg_check_modules(PKG_${component} QUIET "lib${component}")
@@ -33,7 +35,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