aboutsummaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2020-05-08 23:13:46 +0200
committerDaniel Stenberg <daniel@haxx.se>2020-05-10 23:36:41 +0200
commit5bfc874a359c229adf82ab7495c8f7d28dea992e (patch)
tree23c8b65ee4cc240b828390b60a04ee34276aefbb /CMakeLists.txt
parent000f72169092ffca83e571d16ec840c7b840f756 (diff)
CMake: add HTTP/3 support (ngtcp2+nghttp3, quiche)
Add three new CMake Find modules (using the curl license, but I grant others the right to apply the CMake BSD license instead). This CMake config is simpler than the autotools one because it assumes ngtcp2 and nghttp3 to be used together. Another difference is that this CMake config checks whether QUIC is actually supported by the TLS library (patched OpenSSL or boringssl) since this can be a common configuration mistake that could result in build errors later. Unlike autotools, CMake does not warn you that the features are experimental. The user is supposed to already know that and read the documentation. It requires a very special build environment anyway. Tested with ngtcp2+OpenSSL+nghttp3 and quiche+boringssl, both built from current git master. Use `LD_DEBUG=files src/curl |& grep need` to figure out which features (libldap-2.4, libssh2) to disable due to conflicts with boringssl. Closes #5359
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt51
1 files changed, 51 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b8061d14d..616a70db6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -438,6 +438,56 @@ if(USE_NGHTTP2)
list(APPEND CURL_LIBS ${NGHTTP2_LIBRARIES})
endif()
+function(CheckQuicSupportInOpenSSL)
+ # Be sure that the OpenSSL library actually supports QUIC.
+ cmake_push_check_state()
+ set(CMAKE_REQUIRED_INCLUDES "${OPENSSL_INCLUDE_DIR}")
+ set(CMAKE_REQUIRED_LIBRARIES "${OPENSSL_LIBRARIES}")
+ check_symbol_exists(SSL_CTX_set_quic_method "openssl/ssl.h" HAVE_SSL_CTX_SET_QUIC_METHOD)
+ if(NOT HAVE_SSL_CTX_SET_QUIC_METHOD)
+ message(FATAL_ERROR "QUIC support is missing in OpenSSL/boringssl. Try setting -DOPENSSL_ROOT_DIR")
+ endif()
+ cmake_pop_check_state()
+endfunction()
+
+option(USE_NGTCP2 "Use ngtcp2 and nghttp3 libraries for HTTP/3 support" OFF)
+if(USE_NGTCP2)
+ if(USE_OPENSSL)
+ find_package(NGTCP2 REQUIRED OpenSSL)
+ CheckQuicSupportInOpenSSL()
+ elseif(USE_GNUTLS)
+ # TODO add GnuTLS support as vtls library.
+ find_package(NGTCP2 REQUIRED GnuTLS)
+ else()
+ message(FATAL_ERROR "ngtcp2 requires OpenSSL or GnuTLS")
+ endif()
+ set(USE_NGTCP2 ON)
+ include_directories(${NGTCP2_INCLUDE_DIRS})
+ list(APPEND CURL_LIBS ${NGTCP2_LIBRARIES})
+
+ find_package(NGHTTP3 REQUIRED)
+ set(USE_NGHTTP3 ON)
+ include_directories(${NGHTTP3_INCLUDE_DIRS})
+ list(APPEND CURL_LIBS ${NGHTTP3_LIBRARIES})
+endif()
+
+option(USE_QUICHE "Use quiche library for HTTP/3 support" OFF)
+if(USE_QUICHE)
+ if(USE_NGTCP2)
+ message(FATAL_ERROR "Only one HTTP/3 backend can be selected!")
+ endif()
+ find_package(QUICHE REQUIRED)
+ CheckQuicSupportInOpenSSL()
+ set(USE_QUICHE ON)
+ include_directories(${QUICHE_INCLUDE_DIRS})
+ list(APPEND CURL_LIBS ${QUICHE_LIBRARIES})
+ cmake_push_check_state()
+ set(CMAKE_REQUIRED_INCLUDES "${QUICHE_INCLUDE_DIRS}")
+ set(CMAKE_REQUIRED_LIBRARIES "${QUICHE_LIBRARIES}")
+ check_symbol_exists(quiche_conn_set_qlog_fd "quiche.h" HAVE_QUICHE_CONN_SET_QLOG_FD)
+ cmake_pop_check_state()
+endif()
+
if(WIN32)
set(USE_WIN32_CRYPTO ON)
endif()
@@ -1276,6 +1326,7 @@ _add_if("NTLM_WB" use_ntlm AND NOT CURL_DISABLE_HTTP AND NTLM_WB_ENABLED)
_add_if("TLS-SRP" USE_TLS_SRP)
# TODO option --with-nghttp2 tests for nghttp2 lib and nghttp2/nghttp2.h header
_add_if("HTTP2" USE_NGHTTP2)
+_add_if("HTTP3" USE_NGTCP2 OR USE_QUICHE)
_add_if("HTTPS-proxy" SSL_ENABLED AND (USE_OPENSSL OR USE_GNUTLS OR USE_NSS))
string(REPLACE ";" " " SUPPORT_FEATURES "${_items}")
message(STATUS "Enabled features: ${SUPPORT_FEATURES}")