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