1 #***************************************************************************
3 # Project ___| | | | _ \| |
5 # | (__| |_| | _ <| |___
6 # \___|\___/|_| \_\_____|
8 # Copyright (C) 1998 - 2020, 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 ###########################################################################
23 #[=======================================================================[.rst:
27 Find the ngtcp2 library
29 This module accepts optional COMPONENTS to control the crypto library (these are
32 OpenSSL: Use libngtcp2_crypto_openssl
33 GnuTLS: Use libngtcp2_crypto_gnutls
40 ``NGTCP2_INCLUDE_DIRS``
41 The ngtcp2 include directories.
43 The libraries needed to use ngtcp2
46 #]=======================================================================]
49 find_package(PkgConfig QUIET)
50 pkg_search_module(PC_NGTCP2 libngtcp2)
53 find_path(NGTCP2_INCLUDE_DIR ngtcp2/ngtcp2.h
55 ${PC_NGTCP2_INCLUDEDIR}
56 ${PC_NGTCP2_INCLUDE_DIRS}
59 find_library(NGTCP2_LIBRARY NAMES ngtcp2
62 ${PC_NGTCP2_LIBRARY_DIRS}
66 set(NGTCP2_VERSION ${PC_NGTCP2_VERSION})
69 if(NGTCP2_FIND_COMPONENTS)
70 set(NGTCP2_CRYPTO_BACKEND "")
71 foreach(component IN LISTS NGTCP2_FIND_COMPONENTS)
72 if(component MATCHES "^(OpenSSL|GnuTLS)")
73 if(NGTCP2_CRYPTO_BACKEND)
74 message(FATAL_ERROR "NGTCP2: Only one crypto library can be selected")
76 set(NGTCP2_CRYPTO_BACKEND ${component})
80 if(NGTCP2_CRYPTO_BACKEND)
81 string(TOLOWER "ngtcp2_crypto_${NGTCP2_CRYPTO_BACKEND}" _crypto_library)
83 pkg_search_module(PC_${_crypto_library} lib${_crypto_library})
85 find_library(${_crypto_library}_LIBRARY
89 ${PC_${_crypto_library}_LIBDIR}
90 ${PC_${_crypto_library}_LIBRARY_DIRS}
92 if(${_crypto_library}_LIBRARY)
93 set(NGTCP2_${NGTCP2_CRYPTO_BACKEND}_FOUND TRUE)
94 set(NGTCP2_CRYPTO_LIBRARY ${${_crypto_library}_LIBRARY})
99 include(FindPackageHandleStandardArgs)
100 find_package_handle_standard_args(NGTCP2
104 VERSION_VAR NGTCP2_VERSION
109 set(NGTCP2_LIBRARIES ${NGTCP2_LIBRARY} ${NGTCP2_CRYPTO_LIBRARY})
110 set(NGTCP2_INCLUDE_DIRS ${NGTCP2_INCLUDE_DIR})
113 mark_as_advanced(NGTCP2_INCLUDE_DIRS NGTCP2_LIBRARIES)