]> git.proxmox.com Git - ceph.git/blob - ceph/cmake/modules/Findpmem.cmake
import quincy beta 17.1.0
[ceph.git] / ceph / cmake / modules / Findpmem.cmake
1 # - Find pmem
2 #
3 # pmem_INCLUDE_DIRS - Where to find libpmem headers
4 # pmem_LIBRARIES - List of libraries when using libpmem.
5 # pmem_FOUND - True if pmem found.
6
7 find_package(PkgConfig QUIET REQUIRED)
8
9 # all pmem libraries depend on pmem, so always find it
10 set(pmem_FIND_COMPONENTS ${pmem_FIND_COMPONENTS} pmem)
11 list(REMOVE_DUPLICATES pmem_FIND_COMPONENTS)
12
13 foreach(component ${pmem_FIND_COMPONENTS})
14 set(pmem_COMPONENTS pmem pmemobj)
15 list(FIND pmem_COMPONENTS "${component}" found)
16 if(found EQUAL -1)
17 message(FATAL_ERROR "unknown libpmem component: ${component}")
18 endif()
19 pkg_check_modules(PKG_${component} QUIET "lib${component}")
20 if(NOT pmem_VERSION_STRING OR PKG_${component}_VERSION VERSION_LESS pmem_VERSION_STRING)
21 set(pmem_VERSION_STRING ${PKG_${component}_VERSION})
22 endif()
23 find_path(pmem_${component}_INCLUDE_DIR
24 NAMES lib${component}.h
25 HINTS ${PKG_${component}_INCLUDE_DIRS})
26 find_library(pmem_${component}_LIBRARY
27 NAMES ${component}
28 HINTS ${PKG_${component}_LIBRARY_DIRS})
29 mark_as_advanced(
30 pmem_${component}_INCLUDE_DIR
31 pmem_${component}_LIBRARY)
32 list(APPEND pmem_INCLUDE_DIRS "pmem_${component}_INCLUDE_DIR")
33 list(APPEND pmem_LIBRARIES "pmem_${component}_LIBRARY")
34 endforeach()
35
36 include(FindPackageHandleStandardArgs)
37 find_package_handle_standard_args(pmem
38 REQUIRED_VARS pmem_INCLUDE_DIRS pmem_LIBRARIES
39 VERSION_VAR pmem_VERSION_STRING)
40
41 mark_as_advanced(
42 pmem_INCLUDE_DIRS
43 pmem_LIBRARIES)
44
45 if(pmem_FOUND)
46 foreach(component pmem ${pmem_FIND_COMPONENTS})
47 if(NOT TARGET pmem::${component})
48 add_library(pmem::${component} UNKNOWN IMPORTED)
49 set_target_properties(pmem::${component} PROPERTIES
50 INTERFACE_INCLUDE_DIRECTORIES "${pmem_${component}_INCLUDE_DIR}"
51 IMPORTED_LINK_INTERFACE_LANGUAGES "C"
52 IMPORTED_LOCATION "${pmem_${component}_LIBRARY}")
53 # all pmem libraries calls into pmem::pmem
54 if(NOT component STREQUAL pmem)
55 set_target_properties(pmem::${component} PROPERTIES
56 INTERFACE_LINK_LIBRARIES pmem::pmem)
57 endif()
58 endif()
59 endforeach()
60 endif()