[nuraft] Add new port (#28286) (#48596)

This commit is contained in:
lithrad
2025-12-23 16:47:51 -05:00
committed by GitHub
parent 914f5e01f1
commit eb4b421187
6 changed files with 150 additions and 0 deletions
@@ -0,0 +1,81 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0e5ac72..0fb7c75 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -177,9 +177,7 @@ endif(WITH_CONAN)
set(LIBRARIES
${LIBSSL}
${LIBCRYPTO}
- ${LIBBOOST_SYSTEM}
- ${LIBDL}
- ${LIBZ})
+ ${LIBBOOST_SYSTEM})
# === Compiler flags ===
option(USE_PTHREAD_EXIT "Call pthread_exit on server threads" OFF)
@@ -335,10 +333,6 @@ add_library(static_lib ${STATIC_LIB_SRC})
add_library(NuRaft::static_lib ALIAS static_lib)
set_target_properties(static_lib PROPERTIES OUTPUT_NAME ${LIBRARY_NAME} CLEAN_DIRECT_OUTPUT 1)
-add_library(shared_lib SHARED ${STATIC_LIB_SRC})
-add_library(NuRaft::shared_lib ALIAS shared_lib)
-set_target_properties(shared_lib PROPERTIES OUTPUT_NAME ${LIBRARY_NAME} CLEAN_DIRECT_OUTPUT 1)
-
# Include directories are necessary for dependents to use the targets.
target_include_directories(static_lib
PUBLIC
@@ -346,17 +340,25 @@ target_include_directories(static_lib
$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include>
)
-target_include_directories(shared_lib
- PUBLIC
- $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
- $<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include>
-)
-
# if (APPLE)
# There is no harm in adding libraries; this is required when building with Conan
-target_link_libraries(shared_lib ${LIBRARIES})
target_link_libraries(static_lib ${LIBRARIES})
+if(NOT WIN32)
+ set(TARGET_LIST "shared_lib;static_lib")
+ add_library(shared_lib SHARED ${STATIC_LIB_SRC})
+ add_library(NuRaft::shared_lib ALIAS shared_lib)
+ set_target_properties(shared_lib PROPERTIES OUTPUT_NAME ${LIBRARY_NAME} CLEAN_DIRECT_OUTPUT 1)
+ target_include_directories(shared_lib
+ PUBLIC
+ $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
+ $<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include>
+ )
+ target_link_libraries(shared_lib ${LIBRARIES})
+else()
+ set(TARGET_LIST "static_lib")
+endif()
+
# endif ()
if(WIN32)
set(LIBRARY_OUTPUT_NAME "${LIBRARY_NAME}.lib")
@@ -404,7 +406,7 @@ if(CODE_COVERAGE GREATER 0)
endif()
# === Install Targets ===
-install(TARGETS shared_lib static_lib
+install(TARGETS ${TARGET_LIST}
EXPORT nuraft-targets
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
diff --git a/src/tracer.hxx b/src/tracer.hxx
index ac5f100..e10b30a 100644
--- a/src/tracer.hxx
+++ b/src/tracer.hxx
@@ -53,7 +53,7 @@ static inline std::string msg_if_given(const char* format, ...) {
}
// Get rid of newline at the end.
- if ((not msg.empty()) && (msg.back() == '\n')) {
+ if ((!msg.empty()) && (msg.back() == '\n')) {
msg.pop_back();
}
return msg;
+29
View File
@@ -0,0 +1,29 @@
if(VCPKG_TARGET_IS_WINDOWS)
vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
endif()
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO eBay/NuRaft
REF "v${VERSION}"
SHA512 16baaa9921228c48bfee2aa795b0c644228ceeae32430d2782593dd8087978359edcf47e17e551fbf475df22b127097d8d149fc0996c9ade7b5ae7bafd183f62
HEAD_REF master
PATCHES fix-build-compatibility-issues.patch
)
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
-DBUILD_EXAMPLES=OFF
-DBUILD_TESTING=OFF
)
vcpkg_cmake_install()
vcpkg_copy_pdbs()
vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/NuRaft)
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/lib/cmake")
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
+4
View File
@@ -0,0 +1,4 @@
nuraft provides CMake targets:
find_package(NuRaft CONFIG REQUIRED)
target_link_libraries(main PRIVATE NuRaft::static_lib)
+23
View File
@@ -0,0 +1,23 @@
{
"name": "nuraft",
"version": "3.0.0",
"description": "C++ implementation of Raft core logic as a replication library.",
"homepage": "https://github.com/eBay/NuRaft",
"license": "Apache-2.0",
"supports": "!uwp",
"dependencies": [
"asio",
{
"name": "openssl",
"platform": "!windows"
},
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
]
}
+4
View File
@@ -7000,6 +7000,10 @@
"baseline": "2.16.0",
"port-version": 0
},
"nuraft": {
"baseline": "3.0.0",
"port-version": 0
},
"nuspell": {
"baseline": "5.1.6",
"port-version": 0
+9
View File
@@ -0,0 +1,9 @@
{
"versions": [
{
"git-tree": "c951fae11b7cc7bca82814f02a6b2c18a442ab4c",
"version": "3.0.0",
"port-version": 0
}
]
}