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 25#[=======================================================================[.rst: 26FindNGTCP2 27---------- 28 29Find the ngtcp2 library 30 31This module accepts optional COMPONENTS to control the crypto library (these are 32mutually exclusive):: 33 34 quictls, LibreSSL: Use libngtcp2_crypto_quictls 35 BoringSSL, AWS-LC: Use libngtcp2_crypto_boringssl 36 wolfSSL: Use libngtcp2_crypto_wolfssl 37 GnuTLS: Use libngtcp2_crypto_gnutls 38 39Result Variables 40^^^^^^^^^^^^^^^^ 41 42``NGTCP2_FOUND`` 43 System has ngtcp2 44``NGTCP2_INCLUDE_DIRS`` 45 The ngtcp2 include directories. 46``NGTCP2_LIBRARIES`` 47 The libraries needed to use ngtcp2 48``NGTCP2_VERSION`` 49 version of ngtcp2. 50#]=======================================================================] 51 52if(UNIX) 53 find_package(PkgConfig QUIET) 54 pkg_search_module(PC_NGTCP2 libngtcp2) 55endif() 56 57find_path(NGTCP2_INCLUDE_DIR ngtcp2/ngtcp2.h 58 HINTS 59 ${PC_NGTCP2_INCLUDEDIR} 60 ${PC_NGTCP2_INCLUDE_DIRS} 61) 62 63find_library(NGTCP2_LIBRARY NAMES ngtcp2 64 HINTS 65 ${PC_NGTCP2_LIBDIR} 66 ${PC_NGTCP2_LIBRARY_DIRS} 67) 68 69if(PC_NGTCP2_VERSION) 70 set(NGTCP2_VERSION ${PC_NGTCP2_VERSION}) 71endif() 72 73if(NGTCP2_FIND_COMPONENTS) 74 set(NGTCP2_CRYPTO_BACKEND "") 75 foreach(component IN LISTS NGTCP2_FIND_COMPONENTS) 76 if(component MATCHES "^(BoringSSL|quictls|wolfSSL|GnuTLS)") 77 if(NGTCP2_CRYPTO_BACKEND) 78 message(FATAL_ERROR "NGTCP2: Only one crypto library can be selected") 79 endif() 80 set(NGTCP2_CRYPTO_BACKEND ${component}) 81 endif() 82 endforeach() 83 84 if(NGTCP2_CRYPTO_BACKEND) 85 string(TOLOWER "ngtcp2_crypto_${NGTCP2_CRYPTO_BACKEND}" _crypto_library) 86 if(UNIX) 87 pkg_search_module(PC_${_crypto_library} lib${_crypto_library}) 88 endif() 89 find_library(${_crypto_library}_LIBRARY 90 NAMES 91 ${_crypto_library} 92 HINTS 93 ${PC_${_crypto_library}_LIBDIR} 94 ${PC_${_crypto_library}_LIBRARY_DIRS} 95 ) 96 if(${_crypto_library}_LIBRARY) 97 set(NGTCP2_${NGTCP2_CRYPTO_BACKEND}_FOUND TRUE) 98 set(NGTCP2_CRYPTO_LIBRARY ${${_crypto_library}_LIBRARY}) 99 endif() 100 endif() 101endif() 102 103include(FindPackageHandleStandardArgs) 104find_package_handle_standard_args(NGTCP2 105 REQUIRED_VARS 106 NGTCP2_LIBRARY 107 NGTCP2_INCLUDE_DIR 108 VERSION_VAR NGTCP2_VERSION 109 HANDLE_COMPONENTS 110) 111 112if(NGTCP2_FOUND) 113 set(NGTCP2_LIBRARIES ${NGTCP2_LIBRARY} ${NGTCP2_CRYPTO_LIBRARY}) 114 set(NGTCP2_INCLUDE_DIRS ${NGTCP2_INCLUDE_DIR}) 115endif() 116 117mark_as_advanced(NGTCP2_INCLUDE_DIRS NGTCP2_LIBRARIES) 118