Skip to content

Commit

Permalink
[google-cloud-cpp] Support abseil[cxx17]
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Lundborg <daniel.lundborg@sandvik.com>
  • Loading branch information
dllg committed Jan 17, 2022
1 parent 39b17cf commit 2ce28a4
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 2 deletions.
4 changes: 3 additions & 1 deletion ports/google-cloud-cpp/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ vcpkg_from_github(
REF v1.35.0
SHA512 99eabb37ff32ddaf8f646415b50f3843e89fb119646428c16f03060c2787c8d86fa1ac0919ee60c4f6c7a3b71a14eb828ae26a7fc26d928543d72c7ba3268bff
HEAD_REF main
PATCHES
support_absl_cxx17.patch
)

vcpkg_add_to_path(PREPEND "${CURRENT_HOST_INSTALLED_DIR}/tools/grpc")
Expand Down Expand Up @@ -74,7 +76,7 @@ endforeach()

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

vcpkg_copy_pdbs()
33 changes: 33 additions & 0 deletions ports/google-cloud-cpp/support_absl_cxx17.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 369914e04..f89b256f4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -28,8 +28,14 @@ project(
VERSION 1.35.0
LANGUAGES CXX C)

+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)
# Allow applications to override the CMAKE_CXX_STANDARD, but if not set use 11.
-if (NOT CMAKE_CXX_STANDARD)
+elseif (NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 11)
endif ()
if (CMAKE_CXX_STANDARD VERSION_LESS 11)
diff --git a/google/cloud/internal/port_platform.h b/google/cloud/internal/port_platform.h
index c9f34cf4c..e62400431 100644
--- a/google/cloud/internal/port_platform.h
+++ b/google/cloud/internal/port_platform.h
@@ -49,6 +49,8 @@
// Abort compilation if the compiler does not support C++11.
#if GOOGLE_CLOUD_CPP_CPP_VERSION < 201103L
# error "C++11 or newer is required"
+#elif defined(ABSL_USE_CXX17) && GOOGLE_CLOUD_CPP_CPP_VERSION < 201703L
+# error "Compiled to use Abseil with C++17 support, but using with C++ < C++17"
#endif // GOOGLE_CLOUD_CPP_CPP_VERSION < 201103L

// Abort the build if the version of the compiler is too old. With CMake we
1 change: 1 addition & 0 deletions ports/google-cloud-cpp/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "google-cloud-cpp",
"version": "1.35.0",
"port-version": 1,
"description": "C++ Client Libraries for Google Cloud Platform APIs.",
"homepage": "https://github.com/googleapis/google-cloud-cpp",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -2530,7 +2530,7 @@
},
"google-cloud-cpp": {
"baseline": "1.35.0",
"port-version": 0
"port-version": 1
},
"google-cloud-cpp-common": {
"baseline": "alias",
Expand Down

0 comments on commit 2ce28a4

Please sign in to comment.