Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cmake): automatically set ctype=CORD workarounds #13877

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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[@]}"
}
41 changes: 36 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,21 +21,52 @@ if (NOT GOOGLE_CLOUD_CPP_STORAGE_ENABLE_GRPC)
set_target_properties(
google_cloud_cpp_storage_grpc
PROPERTIES EXPORT_NAME "google-cloud-cpp::experimental-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)
set_target_properties(
google_cloud_cpp_storage_protos
PROPERTIES EXPORT_NAME "google-cloud-cpp::storage_protos")

option(
GOOGLE_CLOUD_CPP_ENABLE_CTYPE_CORD_WORKAROUND
[==[Unused, as GCS+gRPC is not enabled.

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)
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