-
Notifications
You must be signed in to change notification settings - Fork 6.5k
/
fix-cxx-standard.patch
96 lines (82 loc) · 2.75 KB
/
fix-cxx-standard.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
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