]>
Commit | Line | Data |
---|---|---|
9f95a23c TL |
1 | # - Find libnl |
2 | # Find the libnl-3 library and includes | |
3 | # | |
4 | # nl_INCLUDE_DIR - where to find netlink.h, etc. | |
5 | # nl_<COMPONENT>_LIBRARY - library when using nl::<COMPONENT>. | |
6 | # nl_FOUND - True if nl found. | |
7 | ||
8 | find_path(nl_INCLUDE_DIR | |
9 | NAMES | |
10 | netlink/netlink.h | |
11 | PATH_SUFFIXES | |
12 | libnl3) | |
13 | ||
14 | foreach(component "core" ${nl_FIND_COMPONENTS}) | |
15 | set(nl_COMPONENTS core cli genl idiag nf route xfrm) | |
16 | list(FIND nl_COMPONENTS "${component}" found) | |
17 | if(found EQUAL -1) | |
18 | message(FATAL_ERROR "unknown libnl-3 component: ${component}") | |
19 | endif() | |
20 | if(component STREQUAL "core") | |
21 | find_library(nl_${component}_LIBRARY nl-3) | |
22 | else() | |
23 | find_library(nl_${component}_LIBRARY nl-${component}-3) | |
24 | endif() | |
25 | list(APPEND nl_LIBRARIES "nl_${component}_LIBRARY") | |
26 | endforeach() | |
27 | ||
28 | include(FindPackageHandleStandardArgs) | |
29 | find_package_handle_standard_args(nl | |
30 | DEFAULT_MSG ${nl_LIBRARIES} nl_INCLUDE_DIR) | |
31 | ||
32 | mark_as_advanced( | |
33 | ${nl_LIBRARIES} | |
34 | nl_INCLUDE_DIR) | |
35 | ||
36 | if(nl_FOUND) | |
37 | foreach(component "core" ${nl_FIND_COMPONENTS}) | |
38 | if(NOT TARGET nl::${component}) | |
39 | add_library(nl::${component} UNKNOWN IMPORTED) | |
40 | set_target_properties(nl::${component} PROPERTIES | |
41 | INTERFACE_INCLUDE_DIRECTORIES "${nl_INCLUDE_DIR}" | |
42 | IMPORTED_LINK_INTERFACE_LANGUAGES "C" | |
43 | IMPORTED_LOCATION "${nl_${component}_LIBRARY}") | |
44 | if(NOT component STREQUAL "core") | |
45 | set_target_properties(nl::${component} PROPERTIES | |
46 | INTERFACE_LINK_LIBRARIES "${nl_core_LIBRARY}") | |
47 | endif() | |
48 | endif() | |
49 | endforeach() | |
50 | endif() |