]>
Commit | Line | Data |
---|---|---|
9f95a23c TL |
1 | # - Find pmem |
2 | # | |
f67539c2 TL |
3 | # pmem_INCLUDE_DIRS - Where to find libpmem headers |
4 | # pmem_LIBRARIES - List of libraries when using libpmem. | |
9f95a23c | 5 | # pmem_FOUND - True if pmem found. |
9f95a23c | 6 | |
20effc67 TL |
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) | |
f67539c2 TL |
17 | message(FATAL_ERROR "unknown libpmem component: ${component}") |
18 | endif() | |
a4b75251 TL |
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}) | |
f67539c2 TL |
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() | |
9f95a23c TL |
35 | |
36 | include(FindPackageHandleStandardArgs) | |
37 | find_package_handle_standard_args(pmem | |
20effc67 TL |
38 | REQUIRED_VARS pmem_INCLUDE_DIRS pmem_LIBRARIES |
39 | VERSION_VAR pmem_VERSION_STRING) | |
9f95a23c TL |
40 | |
41 | mark_as_advanced( | |
f67539c2 TL |
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() | |
9f95a23c | 60 | endif() |