Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update NuRAFT to v2.1.0 #15349

Merged
merged 2 commits into from
Feb 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion recipes/nuraft/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
sources:
"2.1.0":
url: https://github.com/ebay/nuraft/archive/refs/tags/v2.1.0.tar.gz
sha256: 42d19682149cf24ae12de0dabf70d7ad7e71e49fbfa61d565e9b46e2b3cd517f
"2.0.0":
url: https://github.com/ebay/nuraft/archive/refs/tags/v2.0.0.tar.gz
sha256: f7f535f0e5c0417fb9a0ab87514a1b77647fc8e7ed967b85ca611df1cae14023
patches:
"2.1.0":
- patch_file: "patches/1001-cmake_patches.patch"
patch_description: "Provide CMake correct dependency discovery logic."
patch_type: "conan"
"2.0.0":
- patch_file: "patches/0001-cmake_patches.patch"
patch_description: "Provide CMake correct dependency discovery logic."
patch_type: "conan"
sha256: 8147e2f3b950f944433220539376b1c8e0e93207902f48aa2d3bcbca814a674a
2 changes: 1 addition & 1 deletion recipes/nuraft/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def requirements(self):
if self.options.asio == "boost":
self.requires("boost/1.79.0")
else:
self.requires("asio/1.22.1")
self.requires("asio/1.24.0")
self.requires("openssl/1.1.1s")

def validate(self):
Expand Down
151 changes: 151 additions & 0 deletions recipes/nuraft/all/patches/1001-cmake_patches.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 55d29a8..3af27be 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,5 +1,6 @@
cmake_minimum_required(VERSION 3.5)
project(NuRaft VERSION 1.0.0 LANGUAGES CXX)
+set (CMAKE_CXX_STANDARD 11)

# === Build type (default: RelWithDebInfo, O2) ===========
if (NOT CMAKE_BUILD_TYPE)
@@ -26,41 +27,23 @@ endif()


# === Find ASIO ===
-if (BOOST_INCLUDE_PATH AND BOOST_LIBRARY_PATH)
+find_package(OpenSSL CONFIG REQUIRED)
+find_package(Boost CONFIG)
+if (Boost_FOUND)
# If Boost path (both include and library) is given,
# use Boost's ASIO.
- message(STATUS "Boost include path: " ${BOOST_INCLUDE_PATH})
- message(STATUS "Boost library path: " ${BOOST_LIBRARY_PATH})
-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_BOOST_ASIO")
-
- set(ASIO_INCLUDE_DIR ${BOOST_INCLUDE_PATH})
- set(LIBBOOST_SYSTEM "${BOOST_LIBRARY_PATH}/libboost_system.a")
-
+ set(ASIO_DEP boost::boost)
else ()
# If not, ASIO standalone mode.
- FIND_PATH(ASIO_INCLUDE_DIR
- NAME asio.hpp
- HINTS ${PROJECT_SOURCE_DIR}/asio/asio/include
- $ENV{HOME}/local/include
- /opt/local/include
- /usr/local/include
- /usr/include)
-
+ find_package(Asio CONFIG REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DASIO_STANDALONE")
-
-endif ()
-
-if (NOT ASIO_INCLUDE_DIR)
- message(FATAL_ERROR "Can't find ASIO header files")
-else ()
- message(STATUS "ASIO include path: " ${ASIO_INCLUDE_DIR})
+ set(ASIO_DEP asio::asio)
endif ()


# === Includes ===
include_directories(BEFORE ./)
-include_directories(BEFORE ${ASIO_INCLUDE_DIR})
include_directories(BEFORE ${PROJECT_SOURCE_DIR}/include)
include_directories(BEFORE ${PROJECT_SOURCE_DIR}/include/libnuraft)
include_directories(BEFORE ${PROJECT_SOURCE_DIR}/examples)
@@ -81,24 +64,11 @@ endif()
if (NOT WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-pessimizing-move")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
- if (APPLE)
- include_directories(BEFORE
- /usr/local/opt/openssl/include
- )
- link_directories(
- /usr/local/opt/openssl/lib
- )
- else()
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, it's getting a ride from Boost package which needs pthread, so it will be linked to pthread anyway.

- endif ()

else ()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd5045 /wd4571 /wd4774 /wd4820 /wd5039 /wd4626 /wd4625 /wd5026 /wd5027 /wd4623 /wd4996 /wd4530 /wd4267 /wd4244 /W3")
message(STATUS "---- WIN32 ----")
- set(DISABLE_SSL 1)
endif ()

# === Disable SSL ===
@@ -254,6 +224,7 @@ set(RAFT_CORE
${ROOT_SRC}/stat_mgr.cxx
)
add_library(RAFT_CORE_OBJ OBJECT ${RAFT_CORE})
+target_link_libraries(RAFT_CORE_OBJ ${ASIO_DEP} openssl::openssl)

set(STATIC_LIB_SRC
$<TARGET_OBJECTS:RAFT_CORE_OBJ>)
@@ -261,54 +232,11 @@ set(STATIC_LIB_SRC
# === Executables ===
set(LIBRARY_NAME "nuraft")

-add_library(static_lib ${STATIC_LIB_SRC})
-set_target_properties(static_lib PROPERTIES OUTPUT_NAME ${LIBRARY_NAME} CLEAN_DIRECT_OUTPUT 1)
-
-add_library(shared_lib SHARED ${STATIC_LIB_SRC})
-set_target_properties(shared_lib PROPERTIES OUTPUT_NAME ${LIBRARY_NAME} CLEAN_DIRECT_OUTPUT 1)
-if (APPLE)
- target_link_libraries(shared_lib ${LIBRARIES})
-endif ()
-
-if (WIN32)
- set(LIBRARY_OUTPUT_NAME "${LIBRARY_NAME}.lib")
-else ()
- set(LIBRARY_OUTPUT_NAME "lib${LIBRARY_NAME}.a")
-endif ()
-message(STATUS "Output library file name: ${LIBRARY_OUTPUT_NAME}")
-
-# === Examples ===
-add_subdirectory("${PROJECT_SOURCE_DIR}/examples")
+add_library(nuraft ${STATIC_LIB_SRC})
+target_link_libraries(nuraft ${ASIO_DEP} openssl::openssl)


# === Tests ===
-add_subdirectory("${PROJECT_SOURCE_DIR}/tests")
-
-
-if (CODE_COVERAGE GREATER 0)
- set(CODE_COVERAGE_DEPS
- raft_server_test
- failure_test
- asio_service_test
- buffer_test
- serialization_test
- timer_test
- strfmt_test
- stat_mgr_test
- )
-
- # lcov
- SETUP_TARGET_FOR_COVERAGE(
- NAME raft_cov
- EXECUTABLE ./runtests.sh
- DEPENDENCIES ${CODE_COVERAGE_DEPS}
- )
-endif()
-
-
-# === Install Targets ===
-install(TARGETS static_lib ARCHIVE DESTINATION lib)
-install(TARGETS shared_lib LIBRARY DESTINATION lib)
+install(TARGETS nuraft ARCHIVE DESTINATION lib)
+install(TARGETS nuraft LIBRARY DESTINATION lib)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/libnuraft DESTINATION include)
-
-
2 changes: 2 additions & 0 deletions recipes/nuraft/config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
versions:
"2.1.0":
folder: all
"2.0.0":
folder: all