1 #***************************************************************************
3 # Project ___| | | | _ \| |
5 # | (__| |_| | _ <| |___
6 # \___|\___/|_| \_\_____|
8 # Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al.
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.
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.
18 # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 # KIND, either express or implied.
21 # SPDX-License-Identifier: curl
23 ###########################################################################
25 #[=======================================================================[.rst:
29 Find the ngtcp2 library
31 This module accepts optional COMPONENTS to control the crypto library (these are
34 OpenSSL: Use libngtcp2_crypto_openssl
35 GnuTLS: Use libngtcp2_crypto_gnutls
42 ``NGTCP2_INCLUDE_DIRS``
43 The ngtcp2 include directories.
45 The libraries needed to use ngtcp2
48 #]=======================================================================]
51 find_package(PkgConfig QUIET)
52 pkg_search_module(PC_NGTCP2 libngtcp2)
55 find_path(NGTCP2_INCLUDE_DIR ngtcp2/ngtcp2.h
57 ${PC_NGTCP2_INCLUDEDIR}
58 ${PC_NGTCP2_INCLUDE_DIRS}
61 find_library(NGTCP2_LIBRARY NAMES ngtcp2
64 ${PC_NGTCP2_LIBRARY_DIRS}
68 set(NGTCP2_VERSION ${PC_NGTCP2_VERSION})
71 if(NGTCP2_FIND_COMPONENTS)
72 set(NGTCP2_CRYPTO_BACKEND "")
73 foreach(component IN LISTS NGTCP2_FIND_COMPONENTS)
74 if(component MATCHES "^(BoringSSL|OpenSSL|GnuTLS)")
75 if(NGTCP2_CRYPTO_BACKEND)
76 message(FATAL_ERROR "NGTCP2: Only one crypto library can be selected")
78 set(NGTCP2_CRYPTO_BACKEND ${component})
82 if(NGTCP2_CRYPTO_BACKEND)
83 string(TOLOWER "ngtcp2_crypto_${NGTCP2_CRYPTO_BACKEND}" _crypto_library)
85 pkg_search_module(PC_${_crypto_library} lib${_crypto_library})
87 find_library(${_crypto_library}_LIBRARY
91 ${PC_${_crypto_library}_LIBDIR}
92 ${PC_${_crypto_library}_LIBRARY_DIRS}
94 if(${_crypto_library}_LIBRARY)
95 set(NGTCP2_${NGTCP2_CRYPTO_BACKEND}_FOUND TRUE)
96 set(NGTCP2_CRYPTO_LIBRARY ${${_crypto_library}_LIBRARY})
101 include(FindPackageHandleStandardArgs)
102 find_package_handle_standard_args(NGTCP2
106 VERSION_VAR NGTCP2_VERSION
111 set(NGTCP2_LIBRARIES ${NGTCP2_LIBRARY} ${NGTCP2_CRYPTO_LIBRARY})
112 set(NGTCP2_INCLUDE_DIRS ${NGTCP2_INCLUDE_DIR})
115 mark_as_advanced(NGTCP2_INCLUDE_DIRS NGTCP2_LIBRARIES)