aboutsummaryrefslogtreecommitdiff
path: root/ports/abseil
diff options
context:
space:
mode:
authorJack·Boos·Yu <47264268+JackBoosY@users.noreply.github.com>2020-11-20 11:53:48 -0800
committerGitHub <noreply@github.com>2020-11-20 11:53:48 -0800
commit9b72cad7f0c7c3bc364cb471bf624e6cae3e1aef (patch)
tree1b3ddf0236f76e923b5da71e14e588f0afb928ac /ports/abseil
parente01aec15e6ddf11022bbcf64bd87eb5e9ddcd036 (diff)
downloadvcpkg-9b72cad7f0c7c3bc364cb471bf624e6cae3e1aef.tar.gz
vcpkg-9b72cad7f0c7c3bc364cb471bf624e6cae3e1aef.zip
[abseil] Re-fix cxx 17 standard, add macro ABSL_USE_CXX17 (#14647)
* [abseil] Re-fix cxx 17 standard, add macro ABSL_USE_CXX17 to `absl-config.cmake` * [grpc] Fix build failure when abseil use cxx 17 standard * Update ports/abseil/portfile.cmake
Diffstat (limited to 'ports/abseil')
-rw-r--r--ports/abseil/fix-cxx-standard.patch96
-rw-r--r--ports/abseil/fix-lnk2019-error.patch40
-rw-r--r--ports/abseil/fix-use-cxx17-stdlib-types.patch40
-rw-r--r--ports/abseil/portfile.cmake30
-rw-r--r--ports/abseil/vcpkg.json1
5 files changed, 108 insertions, 99 deletions
diff --git a/ports/abseil/fix-cxx-standard.patch b/ports/abseil/fix-cxx-standard.patch
new file mode 100644
index 000000000..19e1f54db
--- /dev/null
+++ b/ports/abseil/fix-cxx-standard.patch
@@ -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)
++
+ 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
diff --git a/ports/abseil/fix-lnk2019-error.patch b/ports/abseil/fix-lnk2019-error.patch
deleted file mode 100644
index 645d1e094..000000000
--- a/ports/abseil/fix-lnk2019-error.patch
+++ /dev/null
@@ -1,40 +0,0 @@
-diff --git a/absl/base/options.h b/absl/base/options.h
-index 234137c..1fb77e4 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 0
-
-
- // 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 0
-
-
- // 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 0
-
- // 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 0
-
-
- // ABSL_OPTION_USE_INLINE_NAMESPACE
diff --git a/ports/abseil/fix-use-cxx17-stdlib-types.patch b/ports/abseil/fix-use-cxx17-stdlib-types.patch
deleted file mode 100644
index 86715824d..000000000
--- a/ports/abseil/fix-use-cxx17-stdlib-types.patch
+++ /dev/null
@@ -1,40 +0,0 @@
-diff --git a/absl/base/options.h b/absl/base/options.h
-index 234137c..1fb77e4 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 1
-
-
- // 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 1
-
-
- // 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 1
-
- // 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 1
-
-
- // ABSL_OPTION_USE_INLINE_NAMESPACE
diff --git a/ports/abseil/portfile.cmake b/ports/abseil/portfile.cmake
index 536e88f09..a544c1fe4 100644
--- a/ports/abseil/portfile.cmake
+++ b/ports/abseil/portfile.cmake
@@ -2,37 +2,29 @@ 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}
+ # 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()
diff --git a/ports/abseil/vcpkg.json b/ports/abseil/vcpkg.json
index bd0cd8300..96f3288e8 100644
--- a/ports/abseil/vcpkg.json
+++ b/ports/abseil/vcpkg.json
@@ -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.",