From 9d92ed4dc4d6d691668609641043561137e91401 Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Fri, 30 Jun 2023 09:41:52 +0900 Subject: [PATCH] GH-36329: [C++][CI] Use OpenSSL 3 on macOS (#36336) ### Rationale for this change GitHub Actions self-hosted runner for macOS has /usr/local/include/openssl/ provided by OpenSSL 3 (`openssl@ 3`). Our include paths have `... -isystem /usr/local/include -isystem /usr/local/opt/openssl@ 1.1/include ...`. It means that `/usr/local/include/openssl/...` is used for `#include `. If we mix OpenSSL 3 headers and OpenSSL 1.1 libraries, we may get some problems such as a link error. ### What changes are included in this PR? This uses OpenSSL 3 instead of OpenSSL 1.1 because GitHub Actions self-hosted runner for macOS provides OpenSSL 3 by /usr/local/include/openssl/. Note that `$(brew --prefix openssl@ 3)/include` isn't linked as /usr/local/include/openssl` by default. So I think that Homebrew GitHub Actions self-hosted runner for macOS does it explicitly. Other solution: Unlinking `/usr/local/include/openssl` by `brew unlink openssl@ 3`. But there is no reason to use OpenSSL 1.1 for us. So this PR doesn't use this solution. ### Are these changes tested? Yes. ### Are there any user-facing changes? Yes. * Closes: #36329 Authored-by: Sutou Kouhei Signed-off-by: Sutou Kouhei --- cpp/Brewfile | 2 +- cpp/cmake_modules/FindOpenSSLAlt.cmake | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/cpp/Brewfile b/cpp/Brewfile index 66f1bd332bbf9..580e8d3f115d5 100644 --- a/cpp/Brewfile +++ b/cpp/Brewfile @@ -30,7 +30,7 @@ brew "grpc" brew "llvm@14" brew "lz4" brew "ninja" -brew "openssl@1.1" +brew "openssl@3" brew "protobuf" brew "python" brew "rapidjson" diff --git a/cpp/cmake_modules/FindOpenSSLAlt.cmake b/cpp/cmake_modules/FindOpenSSLAlt.cmake index f027eb1026dde..03c61e6ea2ad5 100644 --- a/cpp/cmake_modules/FindOpenSSLAlt.cmake +++ b/cpp/cmake_modules/FindOpenSSLAlt.cmake @@ -22,19 +22,19 @@ endif() if(APPLE AND NOT OPENSSL_ROOT_DIR) find_program(BREW brew) if(BREW) - execute_process(COMMAND ${BREW} --prefix "openssl@1.1" - OUTPUT_VARIABLE OPENSSL11_BREW_PREFIX - OUTPUT_STRIP_TRAILING_WHITESPACE) - if(OPENSSL11_BREW_PREFIX) - set(OPENSSL_ROOT_DIR ${OPENSSL11_BREW_PREFIX}) - else() - execute_process(COMMAND ${BREW} --prefix "openssl" - OUTPUT_VARIABLE OPENSSL_BREW_PREFIX + foreach(BREW_OPENSSL_VERSION "" "3" "3.0" "1.1") + set(BREW_OPENSSL_PACKAGE "openssl") + if(BREW_OPENSSL_VERSION) + string(APPEND BREW_OPENSSL_PACKAGE "@${BREW_OPENSSL_VERSION}") + endif() + execute_process(COMMAND ${BREW} --prefix --installed ${BREW_OPENSSL_PACKAGE} + OUTPUT_VARIABLE BREW_OPENSSL_PREFIX OUTPUT_STRIP_TRAILING_WHITESPACE) - if(OPENSSL_BREW_PREFIX) - set(OPENSSL_ROOT_DIR ${OPENSSL_BREW_PREFIX}) + if(BREW_OPENSSL_PREFIX) + set(OPENSSL_ROOT_DIR ${BREW_OPENSSL_PREFIX}) + break() endif() - endif() + endforeach() endif() endif()