[leveldb] Fix find and use depencencies (#23048)

* [leveldb] Fix find and use depencencies

* version

* Update ports/leveldb/portfile.cmake

Co-authored-by: LilyWangLL <94091114+LilyWangLL@users.noreply.github.com>

* Update ports/leveldb/portfile.cmake

Co-authored-by: LilyWangLL <94091114+LilyWangLL@users.noreply.github.com>

* Update versions/l-/leveldb.json

Co-authored-by: LilyWangLL <94091114+LilyWangLL@users.noreply.github.com>
This commit is contained in:
Jack·Boos·Yu 2022-02-16 12:34:42 +08:00 committed by GitHub
parent 3b07b8e974
commit 81d6c5ec18
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 103 additions and 19 deletions

View File

@ -1,7 +1,7 @@
{
"name": "brpc",
"version-string": "0.9.7",
"port-version": 5,
"port-version": 6,
"description": "Industrial-grade RPC framework used throughout Baidu, with 1,000,000+ instances and thousands kinds of services, called \"baidu-rpc\" inside Baidu.",
"homepage": "https://github.com/apache/incubator-brpc",
"license": "Apache-2.0",
@ -9,7 +9,10 @@
"dependencies": [
"gflags",
"glog",
"leveldb",
{
"name": "leveldb",
"default-features": false
},
"openssl",
{
"name": "protobuf",

View File

@ -0,0 +1,34 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 98b87dc..76d2e9b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -35,8 +35,14 @@ include(CheckIncludeFile)
check_include_file("unistd.h" HAVE_UNISTD_H)
include(CheckLibraryExists)
-check_library_exists(crc32c crc32c_value "" HAVE_CRC32C)
-check_library_exists(snappy snappy_compress "" HAVE_SNAPPY)
+if (WITH_CRC32C)
+ find_package(Crc32c CONFIG REQUIRED)
+ set(HAVE_CRC32C 1)
+endif()
+if (WITH_SNAPPY)
+ find_package(Snappy CONFIG REQUIRED)
+ set(HAVE_SNAPPY 1)
+endif()
check_library_exists(tcmalloc malloc "" HAVE_TCMALLOC)
include(CheckCXXSymbolExists)
@@ -246,10 +252,10 @@ if(HAVE_CLANG_THREAD_SAFETY)
endif(HAVE_CLANG_THREAD_SAFETY)
if(HAVE_CRC32C)
- target_link_libraries(leveldb crc32c)
+ target_link_libraries(leveldb Crc32c::crc32c)
endif(HAVE_CRC32C)
if(HAVE_SNAPPY)
- target_link_libraries(leveldb snappy)
+ target_link_libraries(leveldb Snappy::snappy)
endif(HAVE_SNAPPY)
if(HAVE_TCMALLOC)
target_link_libraries(leveldb tcmalloc)

View File

@ -3,4 +3,11 @@ include(CMakeFindDependencyMacro)
set_and_check(leveldb_INCLUDE_DIR "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@")
if (@WITH_CRC32C@)
find_depedency(Crc32c CONFIG)
endif()
if (@WITH_SNAPPY@)
find_depedency(Snappy CONFIG)
endif()
include("${CMAKE_CURRENT_LIST_DIR}/leveldbTargets.cmake")

View File

@ -1,7 +1,3 @@
if (VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
message(FATAL_ERROR "leveldb doesn't supports UWP")
endif()
vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
vcpkg_from_github(
@ -12,22 +8,31 @@ vcpkg_from_github(
HEAD_REF master
PATCHES
fix_config.patch
fix-dependencies.patch
)
file(COPY ${CURRENT_PORT_DIR}/leveldbConfig.cmake.in DESTINATION ${SOURCE_PATH}/cmake)
file(COPY "${CURRENT_PORT_DIR}/leveldbConfig.cmake.in" DESTINATION "${SOURCE_PATH}/cmake")
vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA # Disable this option if project cannot be built with Ninja
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
crc32c WITH_CRC32C
snappy WITH_SNAPPY
)
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS ${FEATURE_OPTIONS}
OPTIONS_DEBUG -DINSTALL_HEADERS=OFF
)
vcpkg_install_cmake()
vcpkg_cmake_install()
vcpkg_fixup_cmake_targets(CONFIG_PATH lib/cmake/leveldb)
vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/${PORT})
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/share)
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share")
# Handle copyright
file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/leveldb RENAME copyright)
file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)

View File

@ -1,8 +1,33 @@
{
"name": "leveldb",
"version-string": "1.22",
"port-version": 2,
"port-version": 3,
"description": "LevelDB is a fast key-value storage library written at Google that provides an ordered mapping from string keys to string values.",
"homepage": "https://github.com/bitcoin-core/leveldb",
"supports": "!uwp"
"license": "BSD-3-Clause",
"supports": "!uwp",
"dependencies": [
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
],
"features": {
"crc32c": {
"description": "Build with crc32c",
"dependencies": [
"crc32c"
]
},
"snappy": {
"description": "Build with snappy",
"dependencies": [
"snappy"
]
}
}
}

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "f658cec9384935d01319d2725a039da7cb5e6c77",
"version-string": "0.9.7",
"port-version": 6
},
{
"git-tree": "eb37098c32016db48b15a29bd31b08087c7b5d0e",
"version-string": "0.9.7",

View File

@ -1146,7 +1146,7 @@
},
"brpc": {
"baseline": "0.9.7",
"port-version": 5
"port-version": 6
},
"brunocodutra-metal": {
"baseline": "2.1.3",
@ -3314,7 +3314,7 @@
},
"leveldb": {
"baseline": "1.22",
"port-version": 2
"port-version": 3
},
"levmar": {
"baseline": "2.6",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "55e42f74e1f541143900887a64661c8c8e4ea713",
"version-string": "1.22",
"port-version": 3
},
{
"git-tree": "d94e4685c15581a8e5740ee6061d8b608645fd31",
"version-string": "1.22",