From 97ab3dcfd6490434202e4ab00b2eaba9449e42a1 Mon Sep 17 00:00:00 2001 From: Derek Mauro Date: Wed, 6 Jul 2022 19:08:47 -0700 Subject: Move Abseil to C++14 minimum Adds policy checks the raise the minimum C++ version to C++14 and the minimum GCC version to GCC 5 Updates the docs to indicate the C++14 minimum. PiperOrigin-RevId: 459401288 Change-Id: I18878f0e13001c57e97e26ad7c9a9c9c12c39265 --- CMake/AbseilHelpers.cmake | 12 ++++++------ CMake/README.md | 4 ++-- CMakeLists.txt | 2 +- README.md | 15 ++++++++------- absl/base/policy_checks.h | 22 ++++++++++++---------- 5 files changed, 29 insertions(+), 26 deletions(-) diff --git a/CMake/AbseilHelpers.cmake b/CMake/AbseilHelpers.cmake index 6d03381b..ebe9ddc8 100644 --- a/CMake/AbseilHelpers.cmake +++ b/CMake/AbseilHelpers.cmake @@ -258,10 +258,10 @@ Cflags: -I\${includedir}${PC_CFLAGS}\n") endif() if(ABSL_PROPAGATE_CXX_STD) - # Abseil libraries require C++11 as the current minimum standard. + # Abseil libraries require C++14 as the current minimum standard. # Top-level application CMake projects should ensure a consistent C++ # standard for all compiled sources by setting CMAKE_CXX_STANDARD. - target_compile_features(${_NAME} PUBLIC cxx_std_11) + target_compile_features(${_NAME} PUBLIC cxx_std_14) else() # Note: This is legacy (before CMake 3.8) behavior. Setting the # target-level CXX_STANDARD property to ABSL_CXX_STANDARD (which is @@ -306,10 +306,10 @@ Cflags: -I\${includedir}${PC_CFLAGS}\n") target_compile_definitions(${_NAME} INTERFACE ${ABSL_CC_LIB_DEFINES}) if(ABSL_PROPAGATE_CXX_STD) - # Abseil libraries require C++11 as the current minimum standard. + # Abseil libraries require C++14 as the current minimum standard. # Top-level application CMake projects should ensure a consistent C++ # standard for all compiled sources by setting CMAKE_CXX_STANDARD. - target_compile_features(${_NAME} INTERFACE cxx_std_11) + target_compile_features(${_NAME} INTERFACE cxx_std_14) # (INTERFACE libraries can't have the CXX_STANDARD property set, so there # is no legacy behavior else case). @@ -418,10 +418,10 @@ function(absl_cc_test) set_property(TARGET ${_NAME} PROPERTY FOLDER ${ABSL_IDE_FOLDER}/test) if(ABSL_PROPAGATE_CXX_STD) - # Abseil libraries require C++11 as the current minimum standard. + # Abseil libraries require C++14 as the current minimum standard. # Top-level application CMake projects should ensure a consistent C++ # standard for all compiled sources by setting CMAKE_CXX_STANDARD. - target_compile_features(${_NAME} PUBLIC cxx_std_11) + target_compile_features(${_NAME} PUBLIC cxx_std_14) else() # Note: This is legacy (before CMake 3.8) behavior. Setting the # target-level CXX_STANDARD property to ABSL_CXX_STANDARD (which is diff --git a/CMake/README.md b/CMake/README.md index 8134615e..0be3b926 100644 --- a/CMake/README.md +++ b/CMake/README.md @@ -43,8 +43,8 @@ cmake_minimum_required(VERSION 3.8.2) project(my_app_project) # Pick the C++ standard to compile with. -# Abseil currently supports C++11, C++14, and C++17. -set(CMAKE_CXX_STANDARD 11) +# Abseil currently supports C++14, C++17, and C++20. +set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) add_subdirectory(abseil-cpp) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8a20d04a..10acf3b7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,7 +64,7 @@ else() endif() option(ABSL_PROPAGATE_CXX_STD - "Use CMake C++ standard meta features (e.g. cxx_std_11) that propagate to targets that link to Abseil" + "Use CMake C++ standard meta features (e.g. cxx_std_14) that propagate to targets that link to Abseil" OFF) # TODO: Default to ON for CMake 3.8 and greater. if((${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.8) AND (NOT ABSL_PROPAGATE_CXX_STD)) message(WARNING "A future Abseil release will default ABSL_PROPAGATE_CXX_STD to ON for CMake 3.8 and up. We recommend enabling this option to ensure your project still builds correctly.") diff --git a/README.md b/README.md index db3a7b44..89790021 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Abseil - C++ Common Libraries The repository contains the Abseil C++ library code. Abseil is an open-source -collection of C++ code (compliant to C++11) designed to augment the C++ +collection of C++ code (compliant to C++14) designed to augment the C++ standard library. ## Table of Contents @@ -85,13 +85,14 @@ Abseil contains the following C++ library components:
The `hash` library contains the hashing framework and default hash functor implementations for hashable types in Abseil. * [`memory`](absl/memory/) -
The `memory` library contains C++11-compatible versions of - `std::make_unique()` and related memory management facilities. +
The `memory` library contains memory management facilities that + augment C++'s `` library. * [`meta`](absl/meta/) -
The `meta` library contains C++11-compatible versions of type checks +
The `meta` library contains compatible versions of type checks available within C++14 and C++17 versions of the C++ `` library. * [`numeric`](absl/numeric/) -
The `numeric` library contains C++11-compatible 128-bit integers. +
The `numeric` library contains 128-bit integer types as well as + implementations of C++20's bitwise math functions. * [`profiling`](absl/profiling/)
The `profiling` library contains utility code for profiling C++ entities. It is currently a private dependency of other Abseil libraries. @@ -100,7 +101,7 @@ Abseil contains the following C++ library components: `absl::Status` and `absl::StatusOr`. * [`strings`](absl/strings/)
The `strings` library contains a variety of strings routines and - utilities, including a C++11-compatible version of the C++17 + utilities, including a C++14-compatible version of the C++17 `std::string_view` type. * [`synchronization`](absl/synchronization/)
The `synchronization` library contains concurrency primitives (Abseil's @@ -112,7 +113,7 @@ Abseil contains the following C++ library components: time zones. * [`types`](absl/types/)
The `types` library contains non-container utility types, like a - C++11-compatible version of the C++17 `std::optional` type. + C++14-compatible version of the C++17 `std::optional` type. * [`utility`](absl/utility/)
The `utility` library contains utility and helper code. diff --git a/absl/base/policy_checks.h b/absl/base/policy_checks.h index 06b32439..d13073c8 100644 --- a/absl/base/policy_checks.h +++ b/absl/base/policy_checks.h @@ -50,11 +50,11 @@ #error "This package requires Visual Studio 2015 Update 2 or higher." #endif -// We support gcc 4.7 and later. +// We support gcc 5 and later. // This minimum will go up. #if defined(__GNUC__) && !defined(__clang__) -#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 7) -#error "This package requires gcc 4.7 or higher." +#if __GNUC__ < 5 +#error "This package requires gcc 5 or higher." #endif #endif @@ -69,13 +69,15 @@ // C++ Version Check // ----------------------------------------------------------------------------- -// Enforce C++11 as the minimum. Note that Visual Studio has not -// advanced __cplusplus despite being good enough for our purposes, so -// so we exempt it from the check. -#if defined(__cplusplus) && !defined(_MSC_VER) -#if __cplusplus < 201103L -#error "C++ versions less than C++11 are not supported." -#endif +// Enforce C++14 as the minimum. +#if defined(_MSVC_LANG) +#if _MSVC_LANG < 201402L +#error "C++ versions less than C++14 are not supported." +#endif // _MSVC_LANG < 201402L +#elif defined(__cplusplus) +#if __cplusplus < 201402L +#error "C++ versions less than C++14 are not supported." +#endif // __cplusplus < 201402L #endif // ----------------------------------------------------------------------------- -- cgit v1.2.3