Skip to content

Commit

Permalink
Simplify Protobuf configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
coryan committed Mar 28, 2024
1 parent db42822 commit 2dfe719
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 22 deletions.
10 changes: 0 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,16 +114,6 @@ option(
OFF)
mark_as_advanced(GOOGLE_CLOUD_CPP_INTERNAL_DOCFX)

option(
GOOGLE_CLOUD_CPP_ENABLE_CTYPE_CORD_WORKAROUND
[==[Enable the workarounds for [ctype = CORD] when using Protobuf < v23.
More details at

https://github.com/googleapis/google-cloud-cpp/blob/main/doc/ctype-cord-workarounds.md
]==]
OFF)
mark_as_advanced(GOOGLE_CLOUD_CPP_ENABLE_CTYPE_CORD_WORKAROUND)

set(GOOGLE_CLOUD_CPP_OVERRIDE_GOOGLEAPIS_URL
""
CACHE
Expand Down
3 changes: 1 addition & 2 deletions ci/cloudbuild/builds/cmake-oldest-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ cmake -GNinja -S . -B cmake-out/build \
"-DCMAKE_TOOLCHAIN_FILE=${vcpkg_root}/scripts/buildsystems/vcpkg.cmake" \
"-DVCPKG_MANIFEST_DIR=ci/etc/oldest-deps" \
"-DVCPKG_FEATURE_FLAGS=versions,manifest" \
"-DGOOGLE_CLOUD_CPP_ENABLE=${ENABLED_FEATURES}" \
"-DGOOGLE_CLOUD_CPP_ENABLE_CTYPE_CORD_WORKAROUND=ON"
"-DGOOGLE_CLOUD_CPP_ENABLE=${ENABLED_FEATURES}"

io::log_h2 "Building"
cmake --build cmake-out/build
Expand Down
3 changes: 1 addition & 2 deletions ci/cloudbuild/builds/m32.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ readonly ENABLED_FEATURES
# This is the build to test with -m32, which requires a toolchain file.
io::run cmake "${cmake_args[@]}" \
"--toolchain" "${PROJECT_ROOT}/ci/etc/m32-toolchain.cmake" \
-DGOOGLE_CLOUD_CPP_ENABLE="${ENABLED_FEATURES}" \
-DGOOGLE_CLOUD_CPP_ENABLE_CTYPE_CORD_WORKAROUND=ON
-DGOOGLE_CLOUD_CPP_ENABLE="${ENABLED_FEATURES}"
io::run cmake --build cmake-out
mapfile -t ctest_args < <(ctest::common_args)
io::run env -C cmake-out ctest "${ctest_args[@]}" -LE "integration-test"
Expand Down
3 changes: 0 additions & 3 deletions ci/gha/builds/lib/cmake.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@ function cmake::vcpkg_args() {
local args
args=(
-DCMAKE_TOOLCHAIN_FILE="${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
# The version of vcpkg we are using ships with Protobuf v21.x, the
# workarounds are required until v23.x.
-DGOOGLE_CLOUD_CPP_ENABLE_CTYPE_CORD_WORKAROUND=ON
)
printf "%s\n" "${args[@]}"
}
30 changes: 25 additions & 5 deletions google/cloud/storage/google_cloud_cpp_storage_grpc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ if (NOT GOOGLE_CLOUD_CPP_STORAGE_ENABLE_GRPC)
set_target_properties(
google_cloud_cpp_storage_grpc
PROPERTIES EXPORT_NAME "google-cloud-cpp::storage_grpc")
if (GOOGLE_CLOUD_CPP_ENABLE_CTYPE_CORD_WORKAROUND)
target_compile_definitions(
google_cloud_cpp_storage_grpc
INTERFACE GOOGLE_CLOUD_CPP_ENABLE_CTYPE_CORD_WORKAROUND)
endif ()
add_library(google_cloud_cpp_storage_protos INTERFACE)
add_library(google-cloud-cpp::storage_protos ALIAS
google_cloud_cpp_storage_protos)
Expand All @@ -36,6 +31,31 @@ else ()
include(GoogleCloudCppLibrary)
google_cloud_cpp_add_library_protos(storage)

set(GOOGLE_CLOUD_CPP_ENABLE_CTYPE_CORD_WORKAROUND_DEFAULT ON)
# Protobuf versions are ... complicated. Protobuf used to call itself
# 3.21.*, 3.20.*, 3.19.*, etc. Then it starts calling itself 22.*, 23.*,
# etc. This may change in the future:
#
# https://github.com/protocolbuffers/protobuf/issues/13103
#
# Guessing the new version scheme is tempting, but probably unwise.
#
# In any case, `ctype=CORD` is supported starting in 23.x.
if (Protobuf_VERSION VERSION_GREATER "23.x")
set(GOOGLE_CLOUD_CPP_ENABLE_CTYPE_CORD_WORKAROUND_DEFAULT OFF)
endif ()
message(GOOGLE_CLOUD_CPP_ENABLE_CTYPE_CORD_WORKAROUND_DEFAULT=
${GOOGLE_CLOUD_CPP_ENABLE_CTYPE_CORD_WORKAROUND_DEFAULT})
option(
GOOGLE_CLOUD_CPP_ENABLE_CTYPE_CORD_WORKAROUND
[==[Enable the workarounds for [ctype = CORD] when using Protobuf < v23.
More details at

https://github.com/googleapis/google-cloud-cpp/blob/main/doc/ctype-cord-workarounds.md
]==]
${GOOGLE_CLOUD_CPP_ENABLE_CTYPE_CORD_WORKAROUND_DEFAULT})
mark_as_advanced(GOOGLE_CLOUD_CPP_ENABLE_CTYPE_CORD_WORKAROUND)

add_library(
google_cloud_cpp_storage_grpc # cmake-format: sort
async/client.cc
Expand Down

0 comments on commit 2dfe719

Please sign in to comment.