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

[abseil] Re-fix cxx 17 standard, add macro ABSL_USE_CXX17 #14647

Merged
merged 3 commits into from
Nov 20, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
96 changes: 96 additions & 0 deletions ports/abseil/fix-cxx-standard.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
diff --git a/CMake/abslConfig.cmake.in b/CMake/abslConfig.cmake.in
index 62d246d..00947cf 100644
--- a/CMake/abslConfig.cmake.in
+++ b/CMake/abslConfig.cmake.in
@@ -6,3 +6,5 @@ find_dependency(Threads)
@PACKAGE_INIT@

include ("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake")
+
+set(ABSL_USE_CXX17 @ABSL_USE_CXX17@)
\ No newline at end of file
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f0af6f6..927f4ed 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -57,6 +57,23 @@ else()
option(ABSL_ENABLE_INSTALL "Enable install rule" ON)
endif()

+# CXX standard
+option(ABSL_USE_CXX17 "Enable CXX 17 standard" OFF)
+
+if (ABSL_USE_CXX17)
+ set(CMAKE_CXX_STANDARD 17)
+ set(STD_ANY 1)
+ set(STD_OPTIONAL 1)
+ set(STD_STRING_VIEW 1)
+ set(STD_VARIANT 1)
+else()
+ set(CMAKE_CXX_STANDARD 11)
+ set(STD_ANY 0)
+ set(STD_OPTIONAL 0)
+ set(STD_STRING_VIEW 0)
+ set(STD_VARIANT 0)
+endif()
+
list(APPEND CMAKE_MODULE_PATH
${CMAKE_CURRENT_LIST_DIR}/CMake
${CMAKE_CURRENT_LIST_DIR}/absl/copts
diff --git a/absl/base/CMakeLists.txt b/absl/base/CMakeLists.txt
index 9ff5aa2..315bee4 100644
--- a/absl/base/CMakeLists.txt
+++ b/absl/base/CMakeLists.txt
@@ -87,6 +87,12 @@ absl_cc_library(
absl::errno_saver
)

+if (NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/options.h.in)
+ file(RENAME ${CMAKE_CURRENT_LIST_DIR}/options.h ${CMAKE_CURRENT_LIST_DIR}/options.h.in)
+endif()
+file(REMOVE ${CMAKE_CURRENT_LIST_DIR}/options.h)
+configure_file(${CMAKE_CURRENT_LIST_DIR}/options.h.in ${CMAKE_CURRENT_LIST_DIR}/options.h @ONLY)
Comment on lines +48 to +52
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Support --editable mode.

+
absl_cc_library(
NAME
config
diff --git a/absl/base/options.h b/absl/base/options.h
index 6a0fb07..54a9780 100644
--- a/absl/base/options.h
+++ b/absl/base/options.h
@@ -100,7 +100,7 @@
// User code should not inspect this macro. To check in the preprocessor if
// absl::any is a typedef of std::any, use the feature macro ABSL_USES_STD_ANY.

-#define ABSL_OPTION_USE_STD_ANY 2
+#define ABSL_OPTION_USE_STD_ANY @STD_ANY@


// ABSL_OPTION_USE_STD_OPTIONAL
@@ -127,7 +127,7 @@
// absl::optional is a typedef of std::optional, use the feature macro
// ABSL_USES_STD_OPTIONAL.

-#define ABSL_OPTION_USE_STD_OPTIONAL 2
+#define ABSL_OPTION_USE_STD_OPTIONAL @STD_OPTIONAL@


// ABSL_OPTION_USE_STD_STRING_VIEW
@@ -154,7 +154,7 @@
// absl::string_view is a typedef of std::string_view, use the feature macro
// ABSL_USES_STD_STRING_VIEW.

-#define ABSL_OPTION_USE_STD_STRING_VIEW 2
+#define ABSL_OPTION_USE_STD_STRING_VIEW @STD_STRING_VIEW@

// ABSL_OPTION_USE_STD_VARIANT
//
@@ -180,7 +180,7 @@
// absl::variant is a typedef of std::variant, use the feature macro
// ABSL_USES_STD_VARIANT.

-#define ABSL_OPTION_USE_STD_VARIANT 2
+#define ABSL_OPTION_USE_STD_VARIANT @STD_VARIANT@


// ABSL_OPTION_USE_INLINE_NAMESPACE
40 changes: 0 additions & 40 deletions ports/abseil/fix-lnk2019-error.patch

This file was deleted.

40 changes: 0 additions & 40 deletions ports/abseil/fix-use-cxx17-stdlib-types.patch

This file was deleted.

31 changes: 12 additions & 19 deletions ports/abseil/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,30 @@ if (NOT VCPKG_TARGET_IS_WINDOWS)
vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
endif()

if("cxx17" IN_LIST FEATURES)
# in C++17 mode, use std::any, std::optional, std::string_view, std::variant
# instead of the library replacement types
list(APPEND ABSEIL_PATCHES fix-use-cxx17-stdlib-types.patch)
else()
# force use of library replacement types, otherwise the automatic

# detection can cause ABI issues depending on which compiler options
# are enabled for consuming user code
list(APPEND ABSEIL_PATCHES fix-lnk2019-error.patch)
endif()

vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO abseil/abseil-cpp
REF 0f3bb466b868b523cf1dc9b2aaaed65c77b28862 #LTS 20200923, Patch 2
SHA512 17e766a2f7a655a3877eb3accc5745a910b69a5e2426b7ce7f6d31095523dd32d48a709c5f8380488b4cb93ce9faadedc08f0481dbdbd00cf68831541d724b4d
HEAD_REF master
PATCHES ${ABSEIL_PATCHES}
set(ABSL_USE_CXX17 ON)
JackBoosY marked this conversation as resolved.
Show resolved Hide resolved
# in C++17 mode, use std::any, std::optional, std::string_view, std::variant
# instead of the library replacement types
# in C++11 mode, force use of library replacement types, otherwise the automatic
# detection can cause ABI issues depending on which compiler options
# are enabled for consuming user code
PATCHES fix-cxx-standard.patch
)

set(CMAKE_CXX_STANDARD 11)
if("cxx17" IN_LIST FEATURES)
set(CMAKE_CXX_STANDARD 17)
endif()
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
cxx17 ABSL_USE_CXX17
)

vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
OPTIONS
-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}
DISABLE_PARALLEL_CONFIGURE
OPTIONS ${FEATURE_OPTIONS}
)

vcpkg_install_cmake()
Expand Down
1 change: 1 addition & 0 deletions ports/abseil/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "abseil",
"version-string": "2020-09-23",
"port-version": 1,
"description": [
"an open-source collection designed to augment the C++ standard library.",
"Abseil is an open-source collection of C++ library code designed to augment the C++ standard library. The Abseil library code is collected from Google's own C++ code base, has been extensively tested and used in production, and is the same code we depend on in our daily coding lives.",
Expand Down
16 changes: 16 additions & 0 deletions ports/grpc/00012-fix-use-cxx17.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1911144..c749d28 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -257,6 +257,11 @@ include(cmake/re2.cmake)
include(cmake/ssl.cmake)
include(cmake/upb.cmake)
include(cmake/zlib.cmake)
+
+if (ABSL_USE_CXX17)
+ message(STATUS "Found absl uses CXX17, enable CXX17 feature.")
+ set(CMAKE_CXX_STANDARD 17)
+endif()

if(_gRPC_PLATFORM_MAC OR _gRPC_PLATFORM_IOS)
set(_gRPC_ALLTARGETS_LIBRARIES ${CMAKE_DL_LIBS} m pthread)
1 change: 1 addition & 0 deletions ports/grpc/CONTROL
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Source: grpc
Version: 1.33.1
Port-Version: 1
Build-Depends: zlib, openssl, protobuf, c-ares (!uwp), upb, abseil, re2
Homepage: https://github.com/grpc/grpc
Description: An RPC library and framework
Expand Down
1 change: 1 addition & 0 deletions ports/grpc/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ vcpkg_from_github(
00010-add-feature-absl-sync.patch
00011-fix-csharp_plugin.patch
snprintf.patch
00012-fix-use-cxx17.patch
)

if((NOT VCPKG_TARGET_IS_LINUX) AND (VCPKG_TARGET_IS_UWP OR VCPKG_TARGET_ARCHITECTURE STREQUAL "arm" OR VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64"))
Expand Down