Skip to content

Commit f336e83

Browse files
committed
ensure C++ standard consistency
revert #7443 it's almost impossible to predict if those headers are available. abseil has a mechanism to detect these headers, trust it. Since we are trying very hard to inject at build time the default C++ standard of the compiler or the one given in profile, it should be fine.
1 parent e5c4fb0 commit f336e83

File tree

6 files changed

+54
-34
lines changed

6 files changed

+54
-34
lines changed

recipes/abseil/all/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.5)
1+
cmake_minimum_required(VERSION 3.8)
22
project(cmake_wrapper)
33

44
include(conanbuildinfo.cmake)

recipes/abseil/all/conandata.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,19 @@ patches:
1818
"20210324.2":
1919
- patch_file: "patches/0003-absl-string-libm.patch"
2020
base_path: "source_subfolder"
21+
- patch_file: "patches/0004-cpp-standard-20210324.patch"
22+
base_path: "source_subfolder"
2123
"20200923.3":
2224
- patch_file: "patches/0003-absl-string-libm.patch"
2325
base_path: "source_subfolder"
26+
- patch_file: "patches/0004-cpp-standard-20200923.patch"
27+
base_path: "source_subfolder"
2428
"20200225.3":
2529
- patch_file: "patches/0001-cmake-install.patch"
2630
base_path: "source_subfolder"
2731
- patch_file: "patches/0002-missing-numeric_limits.h.patch"
2832
base_path: "source_subfolder"
2933
- patch_file: "patches/0003-absl-string-libm.patch"
3034
base_path: "source_subfolder"
35+
- patch_file: "patches/0004-cpp-standard-20200225.patch"
36+
base_path: "source_subfolder"

recipes/abseil/all/conanfile.py

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
required_conan_version = ">=1.43.0"
88

99

10-
class AbseilRecipe(ConanFile):
10+
class AbseilConan(ConanFile):
1111
name = "abseil"
1212
description = "Abseil Common Libraries (C++) from Google"
1313
topics = ("algorithm", "container", "google", "common", "utility")
@@ -65,48 +65,17 @@ def _configure_cmake(self):
6565
if self._cmake:
6666
return self._cmake
6767
self._cmake = CMake(self)
68-
if not tools.valid_min_cppstd(self, 11):
69-
self._cmake.definitions["CMAKE_CXX_STANDARD"] = 11
7068
self._cmake.definitions["ABSL_ENABLE_INSTALL"] = True
69+
self._cmake.definitions["ABSL_PROPAGATE_CXX_STD"] = True
7170
self._cmake.definitions["BUILD_TESTING"] = False
7271
if tools.cross_building(self):
7372
self._cmake.definitions["CONAN_ABSEIL_SYSTEM_PROCESSOR"] = str(self.settings.arch)
7473
self._cmake.configure()
7574
return self._cmake
7675

77-
@property
78-
def _abseil_abi_macros(self):
79-
return [
80-
"ABSL_OPTION_USE_STD_ANY",
81-
"ABSL_OPTION_USE_STD_OPTIONAL",
82-
"ABSL_OPTION_USE_STD_STRING_VIEW",
83-
"ABSL_OPTION_USE_STD_VARIANT",
84-
]
85-
86-
def _abseil_abi_config(self):
87-
"""Determine the Abseil ABI for polyfills (absl::any, absl::optional, absl::string_view, and absl::variant)"""
88-
if self.settings.compiler.get_safe("cppstd"):
89-
if self.settings.compiler.get_safe("cppstd") >= "17":
90-
return "1"
91-
return "0"
92-
# As-of 2021-09-27 only GCC-11 defaults to C++17.
93-
if (
94-
self.settings.compiler == "gcc"
95-
and tools.Version(self.settings.compiler.version) >= "11"
96-
):
97-
return "1"
98-
return "0"
99-
10076
def build(self):
10177
for patch in self.conan_data.get("patches", {}).get(self.version, []):
10278
tools.patch(**patch)
103-
absl_option = self._abseil_abi_config()
104-
for macro in self._abseil_abi_macros:
105-
tools.replace_in_file(
106-
os.path.join(self._source_subfolder, "absl", "base", "options.h"),
107-
"#define {} 2".format(macro),
108-
"#define {} {}".format(macro, absl_option),
109-
)
11079
cmake = self._configure_cmake()
11180
cmake.build()
11281

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--- a/CMake/AbseilHelpers.cmake
2+
+++ b/CMake/AbseilHelpers.cmake
3+
@@ -204,8 +204,12 @@ function(absl_cc_library)
4+
endif()
5+
6+
# INTERFACE libraries can't have the CXX_STANDARD property set
7+
+ if(ABSL_PROPAGATE_CXX_STD)
8+
+ target_compile_features(${_NAME} PUBLIC cxx_std_11)
9+
+ else()
10+
set_property(TARGET ${_NAME} PROPERTY CXX_STANDARD ${ABSL_CXX_STANDARD})
11+
set_property(TARGET ${_NAME} PROPERTY CXX_STANDARD_REQUIRED ON)
12+
+ endif()
13+
14+
# When being installed, we lose the absl_ prefix. We want to put it back
15+
# to have properly named lib files. This is a no-op when we are not being
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--- a/CMake/AbseilHelpers.cmake
2+
+++ b/CMake/AbseilHelpers.cmake
3+
@@ -206,8 +206,12 @@ function(absl_cc_library)
4+
endif()
5+
6+
# INTERFACE libraries can't have the CXX_STANDARD property set
7+
+ if(ABSL_PROPAGATE_CXX_STD)
8+
+ target_compile_features(${_NAME} PUBLIC cxx_std_11)
9+
+ else()
10+
set_property(TARGET ${_NAME} PROPERTY CXX_STANDARD ${ABSL_CXX_STANDARD})
11+
set_property(TARGET ${_NAME} PROPERTY CXX_STANDARD_REQUIRED ON)
12+
+ endif()
13+
14+
# When being installed, we lose the absl_ prefix. We want to put it back
15+
# to have properly named lib files. This is a no-op when we are not being
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--- a/CMake/AbseilHelpers.cmake
2+
+++ b/CMake/AbseilHelpers.cmake
3+
@@ -254,8 +254,12 @@ Cflags: -I\${includedir}${PC_CFLAGS}\n")
4+
endif()
5+
6+
# INTERFACE libraries can't have the CXX_STANDARD property set
7+
+ if(ABSL_PROPAGATE_CXX_STD)
8+
+ target_compile_features(${_NAME} PUBLIC cxx_std_11)
9+
+ else()
10+
set_property(TARGET ${_NAME} PROPERTY CXX_STANDARD ${ABSL_CXX_STANDARD})
11+
set_property(TARGET ${_NAME} PROPERTY CXX_STANDARD_REQUIRED ON)
12+
+ endif()
13+
14+
# When being installed, we lose the absl_ prefix. We want to put it back
15+
# to have properly named lib files. This is a no-op when we are not being

0 commit comments

Comments
 (0)