Skip to content

Commit e8a0cc5

Browse files
authored
build: leverage cmake and bazel to determine when to use OpenSSL API (#15101)
1 parent aaa9169 commit e8a0cc5

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

google/cloud/BUILD.bazel

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,9 @@ cc_library(
270270
"WIN32_LEAN_AND_MEAN",
271271
"_WIN32_WINNT=0x0A00",
272272
],
273-
"//conditions:default": [],
273+
"//conditions:default": [
274+
"GOOGLE_CLOUD_CPP_HAVE_OPENSSL",
275+
],
274276
}),
275277
visibility = ["//:__subpackages__"],
276278
deps = [

google/cloud/google_cloud_cpp_rest_internal.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,11 @@ if (WIN32)
146146
target_link_libraries(google_cloud_cpp_rest_internal PUBLIC ws2_32 bcrypt
147147
crypt32)
148148
else ()
149+
# We already require OpenSSL for non-Windows platforms.
150+
target_compile_definitions(
151+
google_cloud_cpp_rest_internal
152+
PUBLIC # Enable OpenSSL specific functionality.
153+
GOOGLE_CLOUD_CPP_HAVE_OPENSSL)
149154
target_link_libraries(google_cloud_cpp_rest_internal PUBLIC OpenSSL::SSL
150155
OpenSSL::Crypto)
151156
endif ()

google/cloud/internal/curl_handle_factory.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include "google/cloud/internal/curl_options.h"
1818
#include "google/cloud/internal/make_status.h"
1919
#include "google/cloud/log.h"
20-
#ifndef _WIN32
20+
#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENSSL
2121
#include <openssl/err.h>
2222
#include <openssl/ssl.h>
2323
#endif
@@ -30,7 +30,7 @@ namespace rest_internal {
3030
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
3131
namespace {
3232

33-
#ifndef _WIN32
33+
#ifdef GOOGLE_CLOUD_CPP_HAVE_OPENSSL
3434
struct BIOPtrCleanup {
3535
int operator()(BIO* b) const { return BIO_free(b); }
3636
};
@@ -49,7 +49,7 @@ using SSL_CTX = void;
4949
#endif
5050

5151
Status SetCurlCAInMemory(CurlHandleFactory const& factory, SSL_CTX* ssl_ctx) {
52-
#if _WIN32
52+
#ifndef GOOGLE_CLOUD_CPP_HAVE_OPENSSL
5353
return internal::InternalError(
5454
"SSL callback function currently not supported in windows",
5555
GCP_ERROR_INFO());

0 commit comments

Comments
 (0)