Upgrade to 1.46.0
[platform/upstream/nghttp2.git] / cmake / FindLibnghttp3.cmake
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
7 find_package(PkgConfig QUIET)
8 pkg_check_modules(PC_LIBNGHTTP3 QUIET libnghttp3)
9
10 find_path(LIBNGHTTP3_INCLUDE_DIR
11   NAMES nghttp3/nghttp3.h
12   HINTS ${PC_LIBNGHTTP3_INCLUDE_DIRS}
13 )
14 find_library(LIBNGHTTP3_LIBRARY
15   NAMES nghttp3
16   HINTS ${PC_LIBNGHTTP3_LIBRARY_DIRS}
17 )
18
19 if(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)
26 endif()
27
28 include(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.
32 find_package_handle_standard_args(Libnghttp3 REQUIRED_VARS
33                                   LIBNGHTTP3_LIBRARY LIBNGHTTP3_INCLUDE_DIR
34                                   VERSION_VAR LIBNGHTTP3_VERSION)
35
36 if(LIBNGHTTP3_FOUND)
37   set(LIBNGHTTP3_LIBRARIES     ${LIBNGHTTP3_LIBRARY})
38   set(LIBNGHTTP3_INCLUDE_DIRS  ${LIBNGHTTP3_INCLUDE_DIR})
39 endif()
40
41 mark_as_advanced(LIBNGHTTP3_INCLUDE_DIR LIBNGHTTP3_LIBRARY)