# 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}")
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