quickjs-tart

quickjs-based runtime for wallet-core logic
Log | Files | Refs | README | LICENSE

FindNGHTTP3.cmake (3012B)


      1 #***************************************************************************
      2 #                                  _   _ ____  _
      3 #  Project                     ___| | | |  _ \| |
      4 #                             / __| | | | |_) | |
      5 #                            | (__| |_| |  _ <| |___
      6 #                             \___|\___/|_| \_\_____|
      7 #
      8 # Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
      9 #
     10 # This software is licensed as described in the file COPYING, which
     11 # you should have received as part of this distribution. The terms
     12 # are also available at https://curl.se/docs/copyright.html.
     13 #
     14 # You may opt to use, copy, modify, merge, publish, distribute and/or sell
     15 # copies of the Software, and permit persons to whom the Software is
     16 # furnished to do so, under the terms of the COPYING file.
     17 #
     18 # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
     19 # KIND, either express or implied.
     20 #
     21 # SPDX-License-Identifier: curl
     22 #
     23 ###########################################################################
     24 # Find the nghttp3 library
     25 #
     26 # Input variables:
     27 #
     28 # - `NGHTTP3_INCLUDE_DIR`:   The nghttp3 include directory.
     29 # - `NGHTTP3_LIBRARY`:       Path to `nghttp3` library.
     30 #
     31 # Result variables:
     32 #
     33 # - `NGHTTP3_FOUND`:         System has nghttp3.
     34 # - `NGHTTP3_INCLUDE_DIRS`:  The nghttp3 include directories.
     35 # - `NGHTTP3_LIBRARIES`:     The nghttp3 library names.
     36 # - `NGHTTP3_LIBRARY_DIRS`:  The nghttp3 library directories.
     37 # - `NGHTTP3_PC_REQUIRES`:   The nghttp3 pkg-config packages.
     38 # - `NGHTTP3_CFLAGS`:        Required compiler flags.
     39 # - `NGHTTP3_VERSION`:       Version of nghttp3.
     40 
     41 set(NGHTTP3_PC_REQUIRES "libnghttp3")
     42 
     43 if(CURL_USE_PKGCONFIG AND
     44    NOT DEFINED NGHTTP3_INCLUDE_DIR AND
     45    NOT DEFINED NGHTTP3_LIBRARY)
     46   find_package(PkgConfig QUIET)
     47   pkg_check_modules(NGHTTP3 ${NGHTTP3_PC_REQUIRES})
     48 endif()
     49 
     50 if(NGHTTP3_FOUND)
     51   string(REPLACE ";" " " NGHTTP3_CFLAGS "${NGHTTP3_CFLAGS}")
     52   message(STATUS "Found NGHTTP3 (via pkg-config): ${NGHTTP3_INCLUDE_DIRS} (found version \"${NGHTTP3_VERSION}\")")
     53 else()
     54   find_path(NGHTTP3_INCLUDE_DIR NAMES "nghttp3/nghttp3.h")
     55   find_library(NGHTTP3_LIBRARY NAMES "nghttp3")
     56 
     57   unset(NGHTTP3_VERSION CACHE)
     58   if(NGHTTP3_INCLUDE_DIR AND EXISTS "${NGHTTP3_INCLUDE_DIR}/nghttp3/version.h")
     59     set(_version_regex "#[\t ]*define[\t ]+NGHTTP3_VERSION[\t ]+\"([^\"]*)\"")
     60     file(STRINGS "${NGHTTP3_INCLUDE_DIR}/nghttp3/version.h" _version_str REGEX "${_version_regex}")
     61     string(REGEX REPLACE "${_version_regex}" "\\1" _version_str "${_version_str}")
     62     set(NGHTTP3_VERSION "${_version_str}")
     63     unset(_version_regex)
     64     unset(_version_str)
     65   endif()
     66 
     67   include(FindPackageHandleStandardArgs)
     68   find_package_handle_standard_args(NGHTTP3
     69     REQUIRED_VARS
     70       NGHTTP3_INCLUDE_DIR
     71       NGHTTP3_LIBRARY
     72     VERSION_VAR
     73       NGHTTP3_VERSION
     74   )
     75 
     76   if(NGHTTP3_FOUND)
     77     set(NGHTTP3_INCLUDE_DIRS ${NGHTTP3_INCLUDE_DIR})
     78     set(NGHTTP3_LIBRARIES    ${NGHTTP3_LIBRARY})
     79   endif()
     80 
     81   mark_as_advanced(NGHTTP3_INCLUDE_DIR NGHTTP3_LIBRARY)
     82 endif()