aboutsummaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt55
1 files changed, 40 insertions, 15 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 79869ff5..3a9e521f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -14,12 +14,9 @@
# limitations under the License.
#
-# Most widely used distributions have cmake 3.5 or greater available as of March
-# 2019. A notable exception is RHEL-7 (CentOS7). You can install a current
-# version of CMake by first installing Extra Packages for Enterprise Linux
-# (https://fedoraproject.org/wiki/EPEL#Extra_Packages_for_Enterprise_Linux_.28EPEL.29)
-# and then issuing `yum install cmake3` on the command line.
-cmake_minimum_required(VERSION 3.5)
+# https://github.com/google/oss-policies-info/blob/main/foundational-cxx-support-matrix.md
+# As of 2022-09-06, CMake 3.10 is the minimum supported version.
+cmake_minimum_required(VERSION 3.10)
# Compiler id for Apple Clang is now AppleClang.
if (POLICY CMP0025)
@@ -46,7 +43,12 @@ if (POLICY CMP0091)
cmake_policy(SET CMP0091 NEW)
endif (POLICY CMP0091)
-project(absl LANGUAGES CXX VERSION 20220623)
+# try_compile() honors the CMAKE_CXX_STANDARD value
+if (POLICY CMP0067)
+ cmake_policy(SET CMP0067 NEW)
+endif (POLICY CMP0067)
+
+project(absl LANGUAGES CXX VERSION 20230125)
include(CTest)
# Output directory is correct by default for most build setups. However, when
@@ -64,12 +66,16 @@ 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.")
endif()
+option(ABSL_USE_SYSTEM_INCLUDES
+ "Silence warnings in Abseil headers by marking them as SYSTEM includes"
+ OFF)
+
list(APPEND CMAKE_MODULE_PATH
${CMAKE_CURRENT_LIST_DIR}/CMake
${CMAKE_CURRENT_LIST_DIR}/absl/copts
@@ -110,6 +116,10 @@ include(CMakeDependentOption)
option(ABSL_BUILD_TESTING
"If ON, Abseil will build all of Abseil's own tests." OFF)
+option(ABSL_BUILD_TEST_HELPERS
+ "If ON, Abseil will build libraries that you can use to write tests against Abseil code. This option requires that Abseil is configured to use GoogleTest."
+ OFF)
+
option(ABSL_USE_EXTERNAL_GOOGLETEST
"If ON, Abseil will assume that the targets for GoogleTest are already provided by the including project. This makes sense when Abseil is used with add_subdirectory." OFF)
@@ -129,8 +139,7 @@ set(ABSL_LOCAL_GOOGLETEST_DIR "/usr/src/googletest" CACHE PATH
"If ABSL_USE_GOOGLETEST_HEAD is OFF and ABSL_GOOGLETEST_URL is not set, specifies the directory of a local GoogleTest checkout."
)
-if(BUILD_TESTING AND ABSL_BUILD_TESTING)
- ## check targets
+if((BUILD_TESTING AND ABSL_BUILD_TESTING) OR ABSL_BUILD_TEST_HELPERS)
if (ABSL_USE_EXTERNAL_GOOGLETEST)
if (ABSL_FIND_GOOGLETEST)
find_package(GTest REQUIRED)
@@ -162,11 +171,6 @@ if(BUILD_TESTING AND ABSL_BUILD_TESTING)
endif()
include(CMake/Googletest/DownloadGTest.cmake)
endif()
-
- check_target(GTest::gtest)
- check_target(GTest::gtest_main)
- check_target(GTest::gmock)
- check_target(GTest::gmock_main)
endif()
add_subdirectory(absl)
@@ -211,4 +215,25 @@ if(ABSL_ENABLE_INSTALL)
PATTERN "copts" EXCLUDE
PATTERN "testdata" EXCLUDE
)
+
+ file(READ "absl/base/options.h" ABSL_INTERNAL_OPTIONS_H_CONTENTS)
+ if (ABSL_INTERNAL_AT_LEAST_CXX17)
+ string(REGEX REPLACE
+ "#define ABSL_OPTION_USE_STD_([^ ]*) 2"
+ "#define ABSL_OPTION_USE_STD_\\1 1"
+ ABSL_INTERNAL_OPTIONS_H_PINNED
+ "${ABSL_INTERNAL_OPTIONS_H_CONTENTS}")
+ else()
+ string(REGEX REPLACE
+ "#define ABSL_OPTION_USE_STD_([^ ]*) 2"
+ "#define ABSL_OPTION_USE_STD_\\1 0"
+ ABSL_INTERNAL_OPTIONS_H_PINNED
+ "${ABSL_INTERNAL_OPTIONS_H_CONTENTS}")
+ endif()
+ file(WRITE "${CMAKE_BINARY_DIR}/options-pinned.h" "${ABSL_INTERNAL_OPTIONS_H_PINNED}")
+
+ install(FILES "${CMAKE_BINARY_DIR}/options-pinned.h"
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/absl/base
+ RENAME "options.h")
+
endif() # ABSL_ENABLE_INSTALL