• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# - Try to find libnghttp3
2# Once done this will define
3#  LIBNGHTTP3_FOUND        - System has libnghttp3
4#  LIBNGHTTP3_INCLUDE_DIRS - The libnghttp3 include directories
5#  LIBNGHTTP3_LIBRARIES    - The libraries needed to use libnghttp3
6
7find_package(PkgConfig QUIET)
8pkg_check_modules(PC_LIBNGHTTP3 QUIET libnghttp3)
9
10find_path(LIBNGHTTP3_INCLUDE_DIR
11  NAMES nghttp3/nghttp3.h
12  HINTS ${PC_LIBNGHTTP3_INCLUDE_DIRS}
13)
14find_library(LIBNGHTTP3_LIBRARY
15  NAMES nghttp3
16  HINTS ${PC_LIBNGHTTP3_LIBRARY_DIRS}
17)
18
19if(LIBNGHTTP3_INCLUDE_DIR)
20  set(_version_regex "^#define[ \t]+NGHTTP3_VERSION[ \t]+\"([^\"]+)\".*")
21  file(STRINGS "${LIBNGHTTP3_INCLUDE_DIR}/nghttp3/version.h"
22    LIBNGHTTP3_VERSION REGEX "${_version_regex}")
23  string(REGEX REPLACE "${_version_regex}" "\\1"
24    LIBNGHTTP3_VERSION "${LIBNGHTTP3_VERSION}")
25  unset(_version_regex)
26endif()
27
28include(FindPackageHandleStandardArgs)
29# handle the QUIETLY and REQUIRED arguments and set LIBNGHTTP3_FOUND
30# to TRUE if all listed variables are TRUE and the requested version
31# matches.
32find_package_handle_standard_args(Libnghttp3 REQUIRED_VARS
33                                  LIBNGHTTP3_LIBRARY LIBNGHTTP3_INCLUDE_DIR
34                                  VERSION_VAR LIBNGHTTP3_VERSION)
35
36if(LIBNGHTTP3_FOUND)
37  set(LIBNGHTTP3_LIBRARIES     ${LIBNGHTTP3_LIBRARY})
38  set(LIBNGHTTP3_INCLUDE_DIRS  ${LIBNGHTTP3_INCLUDE_DIR})
39endif()
40
41mark_as_advanced(LIBNGHTTP3_INCLUDE_DIR LIBNGHTTP3_LIBRARY)
42