This is an automated email from the ASF dual-hosted git repository.
twice pushed a commit to branch unstable
in repository https://gitbox.apache.org/repos/asf/incubator-kvrocks.git
The following commit(s) were added to refs/heads/unstable by this push:
new 42517c57 Update C++ standard to 17 (#1006)
42517c57 is described below
commit 42517c576f94067b826df732ae1f55c5a390e40f
Author: Twice <[email protected]>
AuthorDate: Tue Oct 18 11:30:36 2022 +0800
Update C++ standard to 17 (#1006)
---
CMakeLists.txt | 24 ++++++++++++++++++++++--
src/common/util.h | 2 +-
2 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 848d6b11..96f1d0e4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -32,6 +32,26 @@ if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
cmake_policy(SET CMP0135 NEW)
endif()
+if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
+ if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7)
+ message(FATAL_ERROR "It is expected to build kvrocks with GCC 7 or
above")
+ endif()
+elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
+ if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5)
+ message(FATAL_ERROR "It is expected to build kvrocks with Clang 5 or
above")
+ endif()
+elseif(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
+ if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 10)
+ message(FATAL_ERROR "It is expected to build kvrocks with Xcode
toolchains 10 or above")
+ endif()
+else()
+ message(WARNING "The compiler you are currently using is not officially
supported,
+ so you can try switching to GCC>=7 or Clang>=5 if you encounter
problems")
+endif()
+
+set(CMAKE_CXX_STANDARD 17)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+
set(DEPS_FETCH_PROXY "" CACHE STRING
"a template URL to proxy the traffic for fetching dependencies, e.g. with
DEPS_FETCH_PROXY = https://some-proxy/,
https://example/some-dep.zip ->
https://some-proxy/https://example/some-dep.zip")
@@ -154,8 +174,8 @@ list(FILTER KVROCKS_SRCS EXCLUDE REGEX src/main.cc)
add_library(kvrocks_objs OBJECT ${KVROCKS_SRCS})
target_include_directories(kvrocks_objs PUBLIC src src/common
${PROJECT_BINARY_DIR})
-target_compile_features(kvrocks_objs PUBLIC cxx_std_11)
-target_compile_options(kvrocks_objs PUBLIC ${WARNING_FLAGS}
-fno-omit-frame-pointer)
+target_compile_features(kvrocks_objs PUBLIC cxx_std_17)
+target_compile_options(kvrocks_objs PUBLIC ${WARNING_FLAGS}
-fno-omit-frame-pointer -Wall -Wpedantic)
target_link_libraries(kvrocks_objs PUBLIC -fno-omit-frame-pointer)
target_link_libraries(kvrocks_objs PUBLIC ${EXTERNAL_LIBS})
if(FOUND_UNWIND_LIB)
diff --git a/src/common/util.h b/src/common/util.h
index 893c3d58..38bd1145 100644
--- a/src/common/util.h
+++ b/src/common/util.h
@@ -75,7 +75,7 @@ uint64_t GetTimeStampUS(void);
// refer to https://en.cppreference.com/w/cpp/memory/unique_ptr/make_unique
template <typename T, typename... Args>
std::unique_ptr<T> MakeUnique(Args &&...args) {
- return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
+ return std::make_unique<T>(std::forward<Args>(args)...);
}
template <typename T, typename... Args>