113498266Sopenharmony_ci#*************************************************************************** 213498266Sopenharmony_ci# _ _ ____ _ 313498266Sopenharmony_ci# Project ___| | | | _ \| | 413498266Sopenharmony_ci# / __| | | | |_) | | 513498266Sopenharmony_ci# | (__| |_| | _ <| |___ 613498266Sopenharmony_ci# \___|\___/|_| \_\_____| 713498266Sopenharmony_ci# 813498266Sopenharmony_ci# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 913498266Sopenharmony_ci# 1013498266Sopenharmony_ci# This software is licensed as described in the file COPYING, which 1113498266Sopenharmony_ci# you should have received as part of this distribution. The terms 1213498266Sopenharmony_ci# are also available at https://curl.se/docs/copyright.html. 1313498266Sopenharmony_ci# 1413498266Sopenharmony_ci# You may opt to use, copy, modify, merge, publish, distribute and/or sell 1513498266Sopenharmony_ci# copies of the Software, and permit persons to whom the Software is 1613498266Sopenharmony_ci# furnished to do so, under the terms of the COPYING file. 1713498266Sopenharmony_ci# 1813498266Sopenharmony_ci# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 1913498266Sopenharmony_ci# KIND, either express or implied. 2013498266Sopenharmony_ci# 2113498266Sopenharmony_ci# SPDX-License-Identifier: curl 2213498266Sopenharmony_ci# 2313498266Sopenharmony_ci########################################################################### 2413498266Sopenharmony_ci 2513498266Sopenharmony_ci#[=======================================================================[.rst: 2613498266Sopenharmony_ciFindNGTCP2 2713498266Sopenharmony_ci---------- 2813498266Sopenharmony_ci 2913498266Sopenharmony_ciFind the ngtcp2 library 3013498266Sopenharmony_ci 3113498266Sopenharmony_ciThis module accepts optional COMPONENTS to control the crypto library (these are 3213498266Sopenharmony_cimutually exclusive):: 3313498266Sopenharmony_ci 3413498266Sopenharmony_ci quictls, LibreSSL: Use libngtcp2_crypto_quictls 3513498266Sopenharmony_ci BoringSSL, AWS-LC: Use libngtcp2_crypto_boringssl 3613498266Sopenharmony_ci wolfSSL: Use libngtcp2_crypto_wolfssl 3713498266Sopenharmony_ci GnuTLS: Use libngtcp2_crypto_gnutls 3813498266Sopenharmony_ci 3913498266Sopenharmony_ciResult Variables 4013498266Sopenharmony_ci^^^^^^^^^^^^^^^^ 4113498266Sopenharmony_ci 4213498266Sopenharmony_ci``NGTCP2_FOUND`` 4313498266Sopenharmony_ci System has ngtcp2 4413498266Sopenharmony_ci``NGTCP2_INCLUDE_DIRS`` 4513498266Sopenharmony_ci The ngtcp2 include directories. 4613498266Sopenharmony_ci``NGTCP2_LIBRARIES`` 4713498266Sopenharmony_ci The libraries needed to use ngtcp2 4813498266Sopenharmony_ci``NGTCP2_VERSION`` 4913498266Sopenharmony_ci version of ngtcp2. 5013498266Sopenharmony_ci#]=======================================================================] 5113498266Sopenharmony_ci 5213498266Sopenharmony_ciif(UNIX) 5313498266Sopenharmony_ci find_package(PkgConfig QUIET) 5413498266Sopenharmony_ci pkg_search_module(PC_NGTCP2 libngtcp2) 5513498266Sopenharmony_ciendif() 5613498266Sopenharmony_ci 5713498266Sopenharmony_cifind_path(NGTCP2_INCLUDE_DIR ngtcp2/ngtcp2.h 5813498266Sopenharmony_ci HINTS 5913498266Sopenharmony_ci ${PC_NGTCP2_INCLUDEDIR} 6013498266Sopenharmony_ci ${PC_NGTCP2_INCLUDE_DIRS} 6113498266Sopenharmony_ci) 6213498266Sopenharmony_ci 6313498266Sopenharmony_cifind_library(NGTCP2_LIBRARY NAMES ngtcp2 6413498266Sopenharmony_ci HINTS 6513498266Sopenharmony_ci ${PC_NGTCP2_LIBDIR} 6613498266Sopenharmony_ci ${PC_NGTCP2_LIBRARY_DIRS} 6713498266Sopenharmony_ci) 6813498266Sopenharmony_ci 6913498266Sopenharmony_ciif(PC_NGTCP2_VERSION) 7013498266Sopenharmony_ci set(NGTCP2_VERSION ${PC_NGTCP2_VERSION}) 7113498266Sopenharmony_ciendif() 7213498266Sopenharmony_ci 7313498266Sopenharmony_ciif(NGTCP2_FIND_COMPONENTS) 7413498266Sopenharmony_ci set(NGTCP2_CRYPTO_BACKEND "") 7513498266Sopenharmony_ci foreach(component IN LISTS NGTCP2_FIND_COMPONENTS) 7613498266Sopenharmony_ci if(component MATCHES "^(BoringSSL|quictls|wolfSSL|GnuTLS)") 7713498266Sopenharmony_ci if(NGTCP2_CRYPTO_BACKEND) 7813498266Sopenharmony_ci message(FATAL_ERROR "NGTCP2: Only one crypto library can be selected") 7913498266Sopenharmony_ci endif() 8013498266Sopenharmony_ci set(NGTCP2_CRYPTO_BACKEND ${component}) 8113498266Sopenharmony_ci endif() 8213498266Sopenharmony_ci endforeach() 8313498266Sopenharmony_ci 8413498266Sopenharmony_ci if(NGTCP2_CRYPTO_BACKEND) 8513498266Sopenharmony_ci string(TOLOWER "ngtcp2_crypto_${NGTCP2_CRYPTO_BACKEND}" _crypto_library) 8613498266Sopenharmony_ci if(UNIX) 8713498266Sopenharmony_ci pkg_search_module(PC_${_crypto_library} lib${_crypto_library}) 8813498266Sopenharmony_ci endif() 8913498266Sopenharmony_ci find_library(${_crypto_library}_LIBRARY 9013498266Sopenharmony_ci NAMES 9113498266Sopenharmony_ci ${_crypto_library} 9213498266Sopenharmony_ci HINTS 9313498266Sopenharmony_ci ${PC_${_crypto_library}_LIBDIR} 9413498266Sopenharmony_ci ${PC_${_crypto_library}_LIBRARY_DIRS} 9513498266Sopenharmony_ci ) 9613498266Sopenharmony_ci if(${_crypto_library}_LIBRARY) 9713498266Sopenharmony_ci set(NGTCP2_${NGTCP2_CRYPTO_BACKEND}_FOUND TRUE) 9813498266Sopenharmony_ci set(NGTCP2_CRYPTO_LIBRARY ${${_crypto_library}_LIBRARY}) 9913498266Sopenharmony_ci endif() 10013498266Sopenharmony_ci endif() 10113498266Sopenharmony_ciendif() 10213498266Sopenharmony_ci 10313498266Sopenharmony_ciinclude(FindPackageHandleStandardArgs) 10413498266Sopenharmony_cifind_package_handle_standard_args(NGTCP2 10513498266Sopenharmony_ci REQUIRED_VARS 10613498266Sopenharmony_ci NGTCP2_LIBRARY 10713498266Sopenharmony_ci NGTCP2_INCLUDE_DIR 10813498266Sopenharmony_ci VERSION_VAR NGTCP2_VERSION 10913498266Sopenharmony_ci HANDLE_COMPONENTS 11013498266Sopenharmony_ci) 11113498266Sopenharmony_ci 11213498266Sopenharmony_ciif(NGTCP2_FOUND) 11313498266Sopenharmony_ci set(NGTCP2_LIBRARIES ${NGTCP2_LIBRARY} ${NGTCP2_CRYPTO_LIBRARY}) 11413498266Sopenharmony_ci set(NGTCP2_INCLUDE_DIRS ${NGTCP2_INCLUDE_DIR}) 11513498266Sopenharmony_ciendif() 11613498266Sopenharmony_ci 11713498266Sopenharmony_cimark_as_advanced(NGTCP2_INCLUDE_DIRS NGTCP2_LIBRARIES) 118