From 9712deecc89b7d977b03c7f0649d228f28780a87 Mon Sep 17 00:00:00 2001 From: Jeremy Maitin-Shepard Date: Sun, 2 Oct 2022 14:55:06 -0700 Subject: [PATCH] Make CMake build more compatible with FetchContent - `HAVE_SSL_IS_QUIC` variable may be used to bypass `check_symbol_exists` call. - it{,prep} targets renamed to nghttp2_it{,prep} --- .github/workflows/build.yml | 2 +- CMakeLists.txt | 16 +++++++++------- integration-tests/CMakeLists.txt | 4 ++-- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ffcd334a..e8ce54ec 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -227,7 +227,7 @@ jobs: if: matrix.buildtool == 'cmake' run: | cd $NGHTTP2_CMAKE_DIR/integration-tests - make itprep it + make nghttp2_itprep nghttp2_it build-cross: strategy: diff --git a/CMakeLists.txt b/CMakeLists.txt index cdd38335..c1021c20 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -198,17 +198,19 @@ include(CheckSymbolExists) set(HAVE_OPENSSL ${OPENSSL_FOUND}) if(OPENSSL_FOUND) set(OPENSSL_INCLUDE_DIRS ${OPENSSL_INCLUDE_DIR}) - cmake_push_check_state() - set(CMAKE_REQUIRED_INCLUDES "${OPENSSL_INCLUDE_DIR}") - set(CMAKE_REQUIRED_LIBRARIES "${OPENSSL_LIBRARIES}") - if(WIN32) - set(CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}" "ws2_32" "bcrypt") + if(NOT (DEFINED HAVE_SSL_IS_QUIC)) + cmake_push_check_state() + set(CMAKE_REQUIRED_INCLUDES "${OPENSSL_INCLUDE_DIR}") + set(CMAKE_REQUIRED_LIBRARIES "${OPENSSL_LIBRARIES}") + if(WIN32) + set(CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}" "ws2_32" "bcrypt") + endif() + check_symbol_exists(SSL_is_quic "openssl/ssl.h" HAVE_SSL_IS_QUIC) + cmake_pop_check_state() endif() - check_symbol_exists(SSL_is_quic "openssl/ssl.h" HAVE_SSL_IS_QUIC) if(NOT HAVE_SSL_IS_QUIC) message(WARNING "OpenSSL in ${OPENSSL_LIBRARIES} does not have SSL_is_quic. HTTP/3 support cannot be enabled") endif() - cmake_pop_check_state() else() set(OPENSSL_INCLUDE_DIRS "") set(OPENSSL_LIBRARIES "") diff --git a/integration-tests/CMakeLists.txt b/integration-tests/CMakeLists.txt index d9385a53..a2d2d5ad 100644 --- a/integration-tests/CMakeLists.txt +++ b/integration-tests/CMakeLists.txt @@ -18,7 +18,7 @@ set(EXTRA_DIST resp-return.rb ) -add_custom_target(itprep +add_custom_target(nghttp2_itprep COMMAND go get -d -v golang.org/x/net/http2 COMMAND go get -d -v github.com/tatsuhiro-t/go-nghttp2 COMMAND go get -d -v golang.org/x/net/websocket @@ -40,7 +40,7 @@ if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR) endforeach() endif() -add_custom_target(it +add_custom_target(nghttp2_it COMMAND sh setenv go test -v DEPENDS ${GO_BUILD_FILES} )