Skip to content
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
1 change: 1 addition & 0 deletions ports/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ After copying the port, add an entry to the table below. You should also contrib
| `azure-storage-common-cpp` | Patching to disable default features on libxml2 (https://github.com/Azure/azure-sdk-for-cpp/pull/5221). |
| `libfaketime` | Port does not yet exist upstream |
| `vcpkg-cmake-config` | Patching to fix build issues with CMake 3.29.1. (https://github.com/microsoft/vcpkg/pull/38017) |
| `google-cloud-cpp` | Patching to remove dependency on GMock. (https://github.com/microsoft/vcpkg/pull/39802) |
86 changes: 86 additions & 0 deletions ports/google-cloud-cpp/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
vcpkg_check_linkage(ONLY_STATIC_LIBRARY)

vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO googleapis/google-cloud-cpp
REF "v${VERSION}"
SHA512 a392da19ac353409ecbf30e390803b2e34670552fd54466a08ee554a77c893d447289b30d5841c7f79b2a23244a269d8ecac8f7fbd8a34dda45ce2d8b1d46817
HEAD_REF main
PATCHES
support_absl_cxx17.patch
remove_gmock.patch
)

if ("grpc-common" IN_LIST FEATURES)
vcpkg_add_to_path(PREPEND "${CURRENT_HOST_INSTALLED_DIR}/tools/grpc")
endif ()

set(GOOGLE_CLOUD_CPP_ENABLE "${FEATURES}")
list(REMOVE_ITEM GOOGLE_CLOUD_CPP_ENABLE "core")
# This feature does not exist, but allows us to simplify the vcpkg.json
# file.
list(REMOVE_ITEM GOOGLE_CLOUD_CPP_ENABLE "grpc-common")
list(REMOVE_ITEM GOOGLE_CLOUD_CPP_ENABLE "rest-common")
list(REMOVE_ITEM GOOGLE_CLOUD_CPP_ENABLE "googleapis")
# google-cloud-cpp uses dialogflow_cx and dialogflow_es. Underscores
# are invalid in `vcpkg` features, we use dashes (`-`) as a separator
# for the `vcpkg` feature name, and convert it here to something that
# `google-cloud-cpp` would like.
if ("dialogflow-cx" IN_LIST FEATURES)
list(REMOVE_ITEM GOOGLE_CLOUD_CPP_ENABLE "dialogflow-cx")
list(APPEND GOOGLE_CLOUD_CPP_ENABLE "dialogflow_cx")
endif ()
if ("dialogflow-es" IN_LIST FEATURES)
list(REMOVE_ITEM GOOGLE_CLOUD_CPP_ENABLE "dialogflow-es")
list(APPEND GOOGLE_CLOUD_CPP_ENABLE "dialogflow_es")
endif ()

vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
DISABLE_PARALLEL_CONFIGURE
OPTIONS
"-DGOOGLE_CLOUD_CPP_ENABLE=${GOOGLE_CLOUD_CPP_ENABLE}"
-DGOOGLE_CLOUD_CPP_ENABLE_MACOS_OPENSSL_CHECK=OFF
-DGOOGLE_CLOUD_CPP_ENABLE_WERROR=OFF
-DGOOGLE_CLOUD_CPP_ENABLE_CCACHE=OFF
-DGOOGLE_CLOUD_CPP_ENABLE_EXAMPLES=OFF
-DBUILD_TESTING=OFF
# This is needed by the `experimental-storage-grpc` feature until vcpkg
# gets Protobuf >= 4.23.0. It has no effect for other features, so
# it is simpler to just always turn it on.
-DGOOGLE_CLOUD_CPP_ENABLE_CTYPE_CORD_WORKAROUND=ON
)

vcpkg_cmake_install()

file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
foreach(feature IN LISTS FEATURES)
set(config_path "lib/cmake/google_cloud_cpp_${feature}")
# Most features get their own package in `google-cloud-cpp`.
# The exceptions are captured by this `if()` command, basically
# things like `core` and `experimental-storage-grpc` are skipped.
if(NOT IS_DIRECTORY "${CURRENT_PACKAGES_DIR}/${config_path}")
continue()
endif()
vcpkg_cmake_config_fixup(PACKAGE_NAME "google_cloud_cpp_${feature}"
CONFIG_PATH "${config_path}"
DO_NOT_DELETE_PARENT_CONFIG_PATH)
endforeach()
# These packages are automatically installed depending on what features are
# enabled.
foreach(suffix common compute_protos googleapis grpc_utils iam_v2 logging_type rest_internal rest_protobuf_internal dialogflow_cx dialogflow_es)
set(config_path "lib/cmake/google_cloud_cpp_${suffix}")
if(NOT IS_DIRECTORY "${CURRENT_PACKAGES_DIR}/${config_path}")
continue()
endif()
vcpkg_cmake_config_fixup(PACKAGE_NAME "google_cloud_cpp_${suffix}"
CONFIG_PATH "${config_path}"
DO_NOT_DELETE_PARENT_CONFIG_PATH)
endforeach()

file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/lib/cmake"
"${CURRENT_PACKAGES_DIR}/debug/lib/cmake"
"${CURRENT_PACKAGES_DIR}/debug/share")
file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)

vcpkg_copy_pdbs()
28 changes: 28 additions & 0 deletions ports/google-cloud-cpp/remove_gmock.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
diff --git a/google/cloud/google_cloud_cpp_common.cmake b/google/cloud/google_cloud_cpp_common.cmake
index 1a14c77..4e8058e 100644
--- a/google/cloud/google_cloud_cpp_common.cmake
+++ b/google/cloud/google_cloud_cpp_common.cmake
@@ -271,9 +271,6 @@ set(google_cloud_cpp_mocks_hdrs
mocks/mock_stream_range.h)
export_list_to_bazel("google_cloud_cpp_mocks.bzl" "google_cloud_cpp_mocks_hdrs"
YEAR "2022")
-target_link_libraries(
- google_cloud_cpp_mocks INTERFACE google-cloud-cpp::common GTest::gmock_main
- GTest::gmock GTest::gtest)
set_target_properties(google_cloud_cpp_mocks PROPERTIES EXPORT_NAME
google-cloud-cpp::mocks)
target_include_directories(
diff --git a/google/cloud/storage/google_cloud_cpp_storage_grpc.cmake b/google/cloud/storage/google_cloud_cpp_storage_grpc.cmake
index a12bb20..eb3182f 100644
--- a/google/cloud/storage/google_cloud_cpp_storage_grpc.cmake
+++ b/google/cloud/storage/google_cloud_cpp_storage_grpc.cmake
@@ -219,9 +219,6 @@ set(google_cloud_cpp_storage_grpc_mocks_hdrs
mocks/mock_async_writer_connection.h)
export_list_to_bazel("google_cloud_cpp_storage_grpc_mocks.bzl"
"google_cloud_cpp_storage_grpc_mocks_hdrs" YEAR "2023")
-target_link_libraries(
- google_cloud_cpp_storage_grpc_mocks
- INTERFACE google-cloud-cpp::experimental-storage_grpc GTest::gmock)
set_target_properties(
google_cloud_cpp_storage_grpc_mocks
PROPERTIES EXPORT_NAME "google-cloud-cpp::experimental-storage_grpc_mocks")
19 changes: 19 additions & 0 deletions ports/google-cloud-cpp/support_absl_cxx17.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3fb0564..b4a251b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -29,6 +29,14 @@ if (NOT "${PROJECT_VERSION_PRE_RELEASE}" STREQUAL "")
set(PROJECT_VERSION "${PROJECT_VERSION}-${PROJECT_VERSION_PRE_RELEASE}")
endif ()

+find_package(absl CONFIG REQUIRED)
+
+# Use CMAKE_CXX_STANDARD=17 if ABSL_USE_CXX17 is set
+if (ABSL_USE_CXX17)
+ message(STATUS "Found absl uses CXX17, enable CXX17 feature.")
+ set(CMAKE_CXX_STANDARD 17)
+endif ()
+
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.3)
message(
Loading