Skip to content

Commit 33034ff

Browse files
teo-tsirpanisKiterLuc
authored andcommitted
Fix google-cloud-cpp build failures on CMake 3.30. (#5167)
[SC-50499](https://app.shortcut.com/tiledb-inc/story/50499/ci-s-updating-of-cmake-3-30-broke-building-the-gcs-port) GitHub Action's recent rollout of CMake 3.30 has broken building the `google-cloud-cpp` port, because it cannot find the `GTest::gmock_main` target (which is otherwise unused for the mainstream building scenario). This PR patches the port to remove the `target_link_libraries` command that links to GMock. Subsequent versions of the Google Cloud client library have added an official option to disable building the mock libraries, and microsoft/vcpkg#39802 has been opened to specify the option in the upstream port. --- TYPE: NO_HISTORY (cherry picked from commit 4c76857)
1 parent af87e3c commit 33034ff

File tree

5 files changed

+1643
-0
lines changed

5 files changed

+1643
-0
lines changed

ports/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,4 @@ After copying the port, add an entry to the table below. You should also contrib
3535
|`pcre2`|To be removed alongside libmagic.|
3636
|`azure-storage-common-cpp`|Patching to disable default features on libxml2 (https://github.com/Azure/azure-sdk-for-cpp/pull/5221).|
3737
|`vcpkg-cmake-config`|Patching to fix build issues with CMake 3.29.1. (https://github.com/microsoft/vcpkg/pull/38017)|
38+
|`google-cloud-cpp`|Patching to remove dependency on GMock. (https://github.com/microsoft/vcpkg/pull/39802)|
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
2+
3+
vcpkg_from_github(
4+
OUT_SOURCE_PATH SOURCE_PATH
5+
REPO googleapis/google-cloud-cpp
6+
REF "v${VERSION}"
7+
SHA512 a392da19ac353409ecbf30e390803b2e34670552fd54466a08ee554a77c893d447289b30d5841c7f79b2a23244a269d8ecac8f7fbd8a34dda45ce2d8b1d46817
8+
HEAD_REF main
9+
PATCHES
10+
support_absl_cxx17.patch
11+
remove_gmock.patch
12+
)
13+
14+
if ("grpc-common" IN_LIST FEATURES)
15+
vcpkg_add_to_path(PREPEND "${CURRENT_HOST_INSTALLED_DIR}/tools/grpc")
16+
endif ()
17+
18+
set(GOOGLE_CLOUD_CPP_ENABLE "${FEATURES}")
19+
list(REMOVE_ITEM GOOGLE_CLOUD_CPP_ENABLE "core")
20+
# This feature does not exist, but allows us to simplify the vcpkg.json
21+
# file.
22+
list(REMOVE_ITEM GOOGLE_CLOUD_CPP_ENABLE "grpc-common")
23+
list(REMOVE_ITEM GOOGLE_CLOUD_CPP_ENABLE "rest-common")
24+
list(REMOVE_ITEM GOOGLE_CLOUD_CPP_ENABLE "googleapis")
25+
# google-cloud-cpp uses dialogflow_cx and dialogflow_es. Underscores
26+
# are invalid in `vcpkg` features, we use dashes (`-`) as a separator
27+
# for the `vcpkg` feature name, and convert it here to something that
28+
# `google-cloud-cpp` would like.
29+
if ("dialogflow-cx" IN_LIST FEATURES)
30+
list(REMOVE_ITEM GOOGLE_CLOUD_CPP_ENABLE "dialogflow-cx")
31+
list(APPEND GOOGLE_CLOUD_CPP_ENABLE "dialogflow_cx")
32+
endif ()
33+
if ("dialogflow-es" IN_LIST FEATURES)
34+
list(REMOVE_ITEM GOOGLE_CLOUD_CPP_ENABLE "dialogflow-es")
35+
list(APPEND GOOGLE_CLOUD_CPP_ENABLE "dialogflow_es")
36+
endif ()
37+
38+
vcpkg_cmake_configure(
39+
SOURCE_PATH "${SOURCE_PATH}"
40+
DISABLE_PARALLEL_CONFIGURE
41+
OPTIONS
42+
"-DGOOGLE_CLOUD_CPP_ENABLE=${GOOGLE_CLOUD_CPP_ENABLE}"
43+
-DGOOGLE_CLOUD_CPP_ENABLE_MACOS_OPENSSL_CHECK=OFF
44+
-DGOOGLE_CLOUD_CPP_ENABLE_WERROR=OFF
45+
-DGOOGLE_CLOUD_CPP_ENABLE_CCACHE=OFF
46+
-DGOOGLE_CLOUD_CPP_ENABLE_EXAMPLES=OFF
47+
-DBUILD_TESTING=OFF
48+
# This is needed by the `experimental-storage-grpc` feature until vcpkg
49+
# gets Protobuf >= 4.23.0. It has no effect for other features, so
50+
# it is simpler to just always turn it on.
51+
-DGOOGLE_CLOUD_CPP_ENABLE_CTYPE_CORD_WORKAROUND=ON
52+
)
53+
54+
vcpkg_cmake_install()
55+
56+
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
57+
foreach(feature IN LISTS FEATURES)
58+
set(config_path "lib/cmake/google_cloud_cpp_${feature}")
59+
# Most features get their own package in `google-cloud-cpp`.
60+
# The exceptions are captured by this `if()` command, basically
61+
# things like `core` and `experimental-storage-grpc` are skipped.
62+
if(NOT IS_DIRECTORY "${CURRENT_PACKAGES_DIR}/${config_path}")
63+
continue()
64+
endif()
65+
vcpkg_cmake_config_fixup(PACKAGE_NAME "google_cloud_cpp_${feature}"
66+
CONFIG_PATH "${config_path}"
67+
DO_NOT_DELETE_PARENT_CONFIG_PATH)
68+
endforeach()
69+
# These packages are automatically installed depending on what features are
70+
# enabled.
71+
foreach(suffix common compute_protos googleapis grpc_utils iam_v2 logging_type rest_internal rest_protobuf_internal dialogflow_cx dialogflow_es)
72+
set(config_path "lib/cmake/google_cloud_cpp_${suffix}")
73+
if(NOT IS_DIRECTORY "${CURRENT_PACKAGES_DIR}/${config_path}")
74+
continue()
75+
endif()
76+
vcpkg_cmake_config_fixup(PACKAGE_NAME "google_cloud_cpp_${suffix}"
77+
CONFIG_PATH "${config_path}"
78+
DO_NOT_DELETE_PARENT_CONFIG_PATH)
79+
endforeach()
80+
81+
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/lib/cmake"
82+
"${CURRENT_PACKAGES_DIR}/debug/lib/cmake"
83+
"${CURRENT_PACKAGES_DIR}/debug/share")
84+
file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
85+
86+
vcpkg_copy_pdbs()
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
diff --git a/google/cloud/google_cloud_cpp_common.cmake b/google/cloud/google_cloud_cpp_common.cmake
2+
index 1a14c77..4e8058e 100644
3+
--- a/google/cloud/google_cloud_cpp_common.cmake
4+
+++ b/google/cloud/google_cloud_cpp_common.cmake
5+
@@ -271,9 +271,6 @@ set(google_cloud_cpp_mocks_hdrs
6+
mocks/mock_stream_range.h)
7+
export_list_to_bazel("google_cloud_cpp_mocks.bzl" "google_cloud_cpp_mocks_hdrs"
8+
YEAR "2022")
9+
-target_link_libraries(
10+
- google_cloud_cpp_mocks INTERFACE google-cloud-cpp::common GTest::gmock_main
11+
- GTest::gmock GTest::gtest)
12+
set_target_properties(google_cloud_cpp_mocks PROPERTIES EXPORT_NAME
13+
google-cloud-cpp::mocks)
14+
target_include_directories(
15+
diff --git a/google/cloud/storage/google_cloud_cpp_storage_grpc.cmake b/google/cloud/storage/google_cloud_cpp_storage_grpc.cmake
16+
index a12bb20..eb3182f 100644
17+
--- a/google/cloud/storage/google_cloud_cpp_storage_grpc.cmake
18+
+++ b/google/cloud/storage/google_cloud_cpp_storage_grpc.cmake
19+
@@ -219,9 +219,6 @@ set(google_cloud_cpp_storage_grpc_mocks_hdrs
20+
mocks/mock_async_writer_connection.h)
21+
export_list_to_bazel("google_cloud_cpp_storage_grpc_mocks.bzl"
22+
"google_cloud_cpp_storage_grpc_mocks_hdrs" YEAR "2023")
23+
-target_link_libraries(
24+
- google_cloud_cpp_storage_grpc_mocks
25+
- INTERFACE google-cloud-cpp::experimental-storage_grpc GTest::gmock)
26+
set_target_properties(
27+
google_cloud_cpp_storage_grpc_mocks
28+
PROPERTIES EXPORT_NAME "google-cloud-cpp::experimental-storage_grpc_mocks")
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
diff --git a/CMakeLists.txt b/CMakeLists.txt
2+
index 3fb0564..b4a251b 100644
3+
--- a/CMakeLists.txt
4+
+++ b/CMakeLists.txt
5+
@@ -29,6 +29,14 @@ if (NOT "${PROJECT_VERSION_PRE_RELEASE}" STREQUAL "")
6+
set(PROJECT_VERSION "${PROJECT_VERSION}-${PROJECT_VERSION_PRE_RELEASE}")
7+
endif ()
8+
9+
+find_package(absl CONFIG REQUIRED)
10+
+
11+
+# Use CMAKE_CXX_STANDARD=17 if ABSL_USE_CXX17 is set
12+
+if (ABSL_USE_CXX17)
13+
+ message(STATUS "Found absl uses CXX17, enable CXX17 feature.")
14+
+ set(CMAKE_CXX_STANDARD 17)
15+
+endif ()
16+
+
17+
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
18+
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.3)
19+
message(

0 commit comments

Comments
 (0)