]> git.proxmox.com Git - ceph.git/blame - ceph/cmake/modules/Findnl.cmake
import 15.2.9
[ceph.git] / ceph / cmake / modules / Findnl.cmake
CommitLineData
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
8find_path(nl_INCLUDE_DIR
9 NAMES
10 netlink/netlink.h
11 PATH_SUFFIXES
12 libnl3)
13
14foreach(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")
26endforeach()
27
28include(FindPackageHandleStandardArgs)
29find_package_handle_standard_args(nl
30 DEFAULT_MSG ${nl_LIBRARIES} nl_INCLUDE_DIR)
31
32mark_as_advanced(
33 ${nl_LIBRARIES}
34 nl_INCLUDE_DIR)
35
36if(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()
50endif()