Imported Upstream version 1.46.0
[platform/upstream/nghttp2.git] / cmake / FindLibbpf.cmake
1 # - Try to find libbpf
2 # Once done this will define
3 #  LIBBPF_FOUND        - System has libbpf
4 #  LIBBPF_INCLUDE_DIRS - The libbpf include directories
5 #  LIBBPF_LIBRARIES    - The libraries needed to use libbpf
6
7 find_package(PkgConfig QUIET)
8 pkg_check_modules(PC_LIBBPF QUIET libbpf)
9
10 find_path(LIBBPF_INCLUDE_DIR
11   NAMES bpf/bpf.h
12   HINTS ${PC_LIBBPF_INCLUDE_DIRS}
13 )
14 find_library(LIBBPF_LIBRARY
15   NAMES bpf
16   HINTS ${PC_LIBBPF_LIBRARY_DIRS}
17 )
18
19 include(FindPackageHandleStandardArgs)
20 # handle the QUIETLY and REQUIRED arguments and set LIBBPF_FOUND
21 # to TRUE if all listed variables are TRUE and the requested version
22 # matches.
23 find_package_handle_standard_args(Libbpf REQUIRED_VARS
24                                   LIBBPF_LIBRARY LIBBPF_INCLUDE_DIR
25                                   VERSION_VAR LIBBPF_VERSION)
26
27 if(LIBBPF_FOUND)
28   set(LIBBPF_LIBRARIES     ${LIBBPF_LIBRARY})
29   set(LIBBPF_INCLUDE_DIRS  ${LIBBPF_INCLUDE_DIR})
30 endif()
31
32 mark_as_advanced(LIBBPF_INCLUDE_DIR LIBBPF_LIBRARY)