mirror of
https://github.com/microsoft/vcpkg.git
synced 2025-06-07 17:12:47 +08:00
[braft] New port (#23830)
* creating braft port * format manifest * version * Refix * version * Add dependency brpc * version * Add license * version * Fix dependency gflags, fix export include path * version * Re-fix dependency * version * Re-fix gflags * version * Add find_dependency * version Co-authored-by: JackBoosY <yuzaiyang@beyondsoft.com>
This commit is contained in:
parent
91dd9ae821
commit
8fc4b4b950
48
ports/braft/export-target.patch
Normal file
48
ports/braft/export-target.patch
Normal file
@ -0,0 +1,48 @@
|
||||
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
|
||||
index 78adc56..ff435a2 100644
|
||||
--- a/src/CMakeLists.txt
|
||||
+++ b/src/CMakeLists.txt
|
||||
@@ -19,8 +19,10 @@ add_library(braft-static STATIC $<TARGET_OBJECTS:OBJ_LIB>)
|
||||
endif()
|
||||
|
||||
if (BUILD_SHARED_LIBS)
|
||||
+target_include_directories(braft-shared PUBLIC $<INSTALL_INTERFACE:include>)
|
||||
target_link_libraries(braft-shared PUBLIC ${DYNAMIC_LIB})
|
||||
else()
|
||||
+target_include_directories(braft-static PUBLIC $<INSTALL_INTERFACE:include>)
|
||||
target_link_libraries(braft-static PUBLIC ${DYNAMIC_LIB})
|
||||
endif()
|
||||
|
||||
@@ -31,15 +33,30 @@ SET_TARGET_PROPERTIES(braft-shared PROPERTIES OUTPUT_NAME braft CLEAN_DIRECT_OUT
|
||||
endif()
|
||||
|
||||
if (NOT BUILD_SHARED_LIBS)
|
||||
-install(TARGETS braft-static
|
||||
+install(TARGETS braft-static EXPORT unofficial-braftTargets
|
||||
RUNTIME DESTINATION bin
|
||||
LIBRARY DESTINATION lib${LIBSUFFIX}
|
||||
ARCHIVE DESTINATION lib${LIBSUFFIX}
|
||||
)
|
||||
else()
|
||||
-install(TARGETS braft-shared
|
||||
+install(TARGETS braft-shared EXPORT unofficial-braftTargets
|
||||
RUNTIME DESTINATION bin
|
||||
LIBRARY DESTINATION lib${LIBSUFFIX}
|
||||
ARCHIVE DESTINATION lib${LIBSUFFIX}
|
||||
)
|
||||
endif()
|
||||
+
|
||||
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/unofficial-braft-config.cmake"
|
||||
+[[include(CMakeFindDependencyMacro)
|
||||
+find_dependency(gflags CONFIG)
|
||||
+file(GLOB TARGET_FILES "${CMAKE_CURRENT_LIST_DIR}/unofficial-braftTargets.cmake")
|
||||
+foreach (TARGET_FILE ${TARGET_FILES})
|
||||
+ include("${TARGET_FILE}")
|
||||
+endforeach()
|
||||
+]])
|
||||
+install(FILES "${CMAKE_CURRENT_BINARY_DIR}/unofficial-braft-config.cmake" DESTINATION share/unofficial-braft)
|
||||
+
|
||||
+install(EXPORT unofficial-braftTargets
|
||||
+ NAMESPACE unofficial::braft::
|
||||
+ DESTINATION share/unofficial-braft
|
||||
+)
|
56
ports/braft/fix-build.patch
Normal file
56
ports/braft/fix-build.patch
Normal file
@ -0,0 +1,56 @@
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index a735c53..53ddaed 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -229,7 +229,9 @@ add_subdirectory(src)
|
||||
if(BUILD_UNIT_TESTS)
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
+if(BUILD_TOOLS)
|
||||
add_subdirectory(tools)
|
||||
+endif()
|
||||
|
||||
file(COPY ${CMAKE_CURRENT_BINARY_DIR}/braft/
|
||||
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/output/include/braft/
|
||||
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
|
||||
index f587464..78adc56 100644
|
||||
--- a/src/CMakeLists.txt
|
||||
+++ b/src/CMakeLists.txt
|
||||
@@ -12,22 +12,34 @@ include_directories(${CMAKE_SOURCE_DIR}/src)
|
||||
add_library(OBJ_LIB OBJECT ${SOURCES})
|
||||
|
||||
set_property(TARGET ${OBJ_LIB} PROPERTY POSITION_INDEPENDENT_CODE 1)
|
||||
+if (BUILD_SHARED_LIBS)
|
||||
add_library(braft-shared SHARED $<TARGET_OBJECTS:OBJ_LIB>)
|
||||
+else()
|
||||
add_library(braft-static STATIC $<TARGET_OBJECTS:OBJ_LIB>)
|
||||
-target_link_libraries(braft-shared ${DYNAMIC_LIB})
|
||||
-target_link_libraries(braft-static ${DYNAMIC_LIB})
|
||||
+endif()
|
||||
+
|
||||
+if (BUILD_SHARED_LIBS)
|
||||
+target_link_libraries(braft-shared PUBLIC ${DYNAMIC_LIB})
|
||||
+else()
|
||||
+target_link_libraries(braft-static PUBLIC ${DYNAMIC_LIB})
|
||||
+endif()
|
||||
|
||||
+if (NOT BUILD_SHARED_LIBS)
|
||||
SET_TARGET_PROPERTIES(braft-static PROPERTIES OUTPUT_NAME braft CLEAN_DIRECT_OUTPUT 1)
|
||||
+else()
|
||||
SET_TARGET_PROPERTIES(braft-shared PROPERTIES OUTPUT_NAME braft CLEAN_DIRECT_OUTPUT 1)
|
||||
+endif()
|
||||
|
||||
+if (NOT BUILD_SHARED_LIBS)
|
||||
install(TARGETS braft-static
|
||||
RUNTIME DESTINATION bin
|
||||
LIBRARY DESTINATION lib${LIBSUFFIX}
|
||||
ARCHIVE DESTINATION lib${LIBSUFFIX}
|
||||
)
|
||||
-
|
||||
+else()
|
||||
install(TARGETS braft-shared
|
||||
RUNTIME DESTINATION bin
|
||||
LIBRARY DESTINATION lib${LIBSUFFIX}
|
||||
ARCHIVE DESTINATION lib${LIBSUFFIX}
|
||||
)
|
||||
+endif()
|
16
ports/braft/fix-dependency.patch
Normal file
16
ports/braft/fix-dependency.patch
Normal file
@ -0,0 +1,16 @@
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index 53ddaed..a851c00 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -47,8 +47,9 @@ if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB))
|
||||
message(FATAL_ERROR "Fail to find leveldb")
|
||||
endif()
|
||||
|
||||
-find_path(GFLAGS_INCLUDE_PATH NAMES gflags/gflags.h)
|
||||
-find_library(GFLAGS_LIB NAMES gflags)
|
||||
+find_package(gflags CONFIG REQUIRED)
|
||||
+get_target_property(GFLAGS_INCLUDE_PATH gflags::gflags INTERFACE_INCLUDE_DIRECTORIES)
|
||||
+set(GFLAGS_LIB gflags::gflags)
|
||||
if ((NOT GFLAGS_INCLUDE_PATH) OR (NOT GFLAGS_LIB))
|
||||
message(FATAL_ERROR "Fail to find gflags")
|
||||
endif()
|
26
ports/braft/portfile.cmake
Normal file
26
ports/braft/portfile.cmake
Normal file
@ -0,0 +1,26 @@
|
||||
vcpkg_from_github(
|
||||
OUT_SOURCE_PATH SOURCE_PATH
|
||||
REPO baidu/braft
|
||||
REF 8d0128e02a2959f9cc427d5f97ed730ee6a6b410
|
||||
SHA512 f28afbf5fe8a354872c252580e2d679f7a66944a554f0c8e9331b8a68b6a87659d59fbbc41c3ada55e09a265032290bcef567c99a7428604d08f7885f97cf6d7
|
||||
HEAD_REF master
|
||||
PATCHES
|
||||
fix-build.patch
|
||||
fix-dependency.patch
|
||||
export-target.patch
|
||||
)
|
||||
|
||||
vcpkg_cmake_configure(
|
||||
SOURCE_PATH "${SOURCE_PATH}"
|
||||
OPTIONS
|
||||
-DBRPC_WITH_GLOG=ON
|
||||
-DBUILD_TOOLS=OFF
|
||||
)
|
||||
vcpkg_cmake_install()
|
||||
vcpkg_copy_pdbs()
|
||||
|
||||
vcpkg_cmake_config_fixup(PACKAGE_NAME unofficial-braft CONFIG_PATH share/unofficial-braft)
|
||||
|
||||
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
|
||||
|
||||
file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
|
24
ports/braft/vcpkg.json
Normal file
24
ports/braft/vcpkg.json
Normal file
@ -0,0 +1,24 @@
|
||||
{
|
||||
"name": "braft",
|
||||
"version-date": "2021-26-04",
|
||||
"description": "Consesus algorithm library",
|
||||
"homepage": "https://github.com/baidu/braft",
|
||||
"license": "Apache-2.0",
|
||||
"supports": "!windows",
|
||||
"dependencies": [
|
||||
"brpc",
|
||||
"gflags",
|
||||
"glog",
|
||||
"leveldb",
|
||||
"protobuf",
|
||||
"thrift",
|
||||
{
|
||||
"name": "vcpkg-cmake",
|
||||
"host": true
|
||||
},
|
||||
{
|
||||
"name": "vcpkg-cmake-config",
|
||||
"host": true
|
||||
}
|
||||
]
|
||||
}
|
9
versions/b-/braft.json
Normal file
9
versions/b-/braft.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"versions": [
|
||||
{
|
||||
"git-tree": "d9afe1afea46ce35f64aaed5c2702c34113fe683",
|
||||
"version-date": "2021-26-04",
|
||||
"port-version": 0
|
||||
}
|
||||
]
|
||||
}
|
@ -1136,6 +1136,10 @@
|
||||
"baseline": "2.4.1",
|
||||
"port-version": 2
|
||||
},
|
||||
"braft": {
|
||||
"baseline": "2021-26-04",
|
||||
"port-version": 0
|
||||
},
|
||||
"breakpad": {
|
||||
"baseline": "2020-09-14",
|
||||
"port-version": 5
|
||||
|
Loading…
Reference in New Issue
Block a user