Switch to `cxx_std_11` as per best current practice.
It requires a version of CMake newer than what Ubuntu Xenial has,
but I should really have bumped up to Ubuntu Bionic a year ago...
Fixes #370.
Change-Id: I1af221e03d80da2df547c63c7ed60016a892885e
Reviewed-on: https://code-review.googlesource.com/c/re2/+/60092
Reviewed-by: Perry Lorier <perryl@google.com>
Reviewed-by: Paul Wankadia <junyer@google.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6edbdcd..e6828d8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,20 +2,14 @@
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
-# Old enough to support Ubuntu Xenial.
-cmake_minimum_required(VERSION 3.5.1)
+# Old enough to support Ubuntu Bionic.
+cmake_minimum_required(VERSION 3.10.2)
project(RE2 CXX)
include(CMakePackageConfigHelpers)
include(CTest)
include(GNUInstallDirs)
-# Unlike GCC and upstream Clang, AppleClang still defaults to `-std=c++98`
-# for some reason. Set CMAKE_CXX_STANDARD if we seem to need to set it. :/
-if(APPLE AND NOT CMAKE_CXX_FLAGS MATCHES "-std=" AND NOT CMAKE_CXX_STANDARD)
- set(CMAKE_CXX_STANDARD 11)
-endif()
-
option(BUILD_SHARED_LIBS "build shared libraries" OFF)
option(USEPCRE "use PCRE in tests and benchmarks" OFF)
@@ -84,6 +78,7 @@
)
add_library(re2 ${RE2_SOURCES})
+target_compile_features(re2 PUBLIC cxx_std_11)
target_include_directories(re2 PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
set_target_properties(re2 PROPERTIES SOVERSION ${SONAME} VERSION ${SONAME}.0.0)
add_library(re2::re2 ALIAS re2)
@@ -105,6 +100,7 @@
)
add_library(testing STATIC ${TESTING_SOURCES})
+ target_compile_features(testing PUBLIC cxx_std_11)
target_link_libraries(testing PUBLIC re2)
set(TEST_TARGETS
@@ -137,12 +133,14 @@
foreach(target ${TEST_TARGETS})
add_executable(${target} re2/testing/${target}.cc util/test.cc)
+ target_compile_features(${target} PUBLIC cxx_std_11)
target_link_libraries(${target} testing ${EXTRA_TARGET_LINK_LIBRARIES})
add_test(NAME ${target} COMMAND ${target})
endforeach()
foreach(target ${BENCHMARK_TARGETS})
add_executable(${target} re2/testing/${target}.cc util/benchmark.cc)
+ target_compile_features(${target} PUBLIC cxx_std_11)
target_link_libraries(${target} testing ${EXTRA_TARGET_LINK_LIBRARIES})
endforeach()
endif()