summaryrefslogtreecommitdiffstats
path: root/cmake/modules/Findpmem.cmake
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
commit19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch)
tree42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /cmake/modules/Findpmem.cmake
parentInitial commit. (diff)
downloadceph-19fcec84d8d7d21e796c7624e521b60d28ee21ed.tar.xz
ceph-19fcec84d8d7d21e796c7624e521b60d28ee21ed.zip
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'cmake/modules/Findpmem.cmake')
-rw-r--r--cmake/modules/Findpmem.cmake57
1 files changed, 57 insertions, 0 deletions
diff --git a/cmake/modules/Findpmem.cmake b/cmake/modules/Findpmem.cmake
new file mode 100644
index 000000000..9c8e21b91
--- /dev/null
+++ b/cmake/modules/Findpmem.cmake
@@ -0,0 +1,57 @@
+# - Find pmem
+#
+# pmem_INCLUDE_DIRS - Where to find libpmem headers
+# 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()
+ message(FATAL_ERROR "unknown libpmem component: ${component}")
+ endif()
+ pkg_check_modules(PKG_${component} QUIET "lib${component}")
+ if(NOT pmem_VERSION_STRING OR PKG_${component}_VERSION VERSION_LESS pmem_VERSION_STRING)
+ set(pmem_VERSION_STRING ${PKG_${component}_VERSION})
+ endif()
+ find_path(pmem_${component}_INCLUDE_DIR
+ NAMES lib${component}.h
+ HINTS ${PKG_${component}_INCLUDE_DIRS})
+ find_library(pmem_${component}_LIBRARY
+ NAMES ${component}
+ HINTS ${PKG_${component}_LIBRARY_DIRS})
+ mark_as_advanced(
+ pmem_${component}_INCLUDE_DIR
+ pmem_${component}_LIBRARY)
+ list(APPEND pmem_INCLUDE_DIRS "pmem_${component}_INCLUDE_DIR")
+ list(APPEND pmem_LIBRARIES "pmem_${component}_LIBRARY")
+endforeach()
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(pmem
+ DEFAULT_MSG pmem_INCLUDE_DIRS pmem_LIBRARIES)
+
+mark_as_advanced(
+ pmem_INCLUDE_DIRS
+ pmem_LIBRARIES)
+
+if(pmem_FOUND)
+ foreach(component pmem ${pmem_FIND_COMPONENTS})
+ if(NOT TARGET pmem::${component})
+ add_library(pmem::${component} UNKNOWN IMPORTED)
+ set_target_properties(pmem::${component} PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${pmem_${component}_INCLUDE_DIR}"
+ IMPORTED_LINK_INTERFACE_LANGUAGES "C"
+ IMPORTED_LOCATION "${pmem_${component}_LIBRARY}")
+ # all pmem libraries calls into pmem::pmem
+ if(NOT component STREQUAL pmem)
+ set_target_properties(pmem::${component} PROPERTIES
+ INTERFACE_LINK_LIBRARIES pmem::pmem)
+ endif()
+ endif()
+ endforeach()
+endif()