Skip to content

Commit

Permalink
Add speedb as a optional dep
Browse files Browse the repository at this point in the history
  • Loading branch information
PragmaTwice committed Oct 1, 2023
1 parent 548d5f5 commit 89849e3
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ option(ENABLE_LUAJIT "enable use of luaJIT instead of lua" ON)
option(ENABLE_OPENSSL "enable openssl to support tls connection" OFF)
option(ENABLE_IPO "enable interprocedural optimization" ON)
option(ENABLE_UNWIND "enable libunwind in glog" ON)
option(ENABLE_SPEEDB "enable speedb instead of rocksdb" OFF)
set(PORTABLE 0 CACHE STRING "build a portable binary (disable arch-specific optimizations)")
# TODO: set ENABLE_NEW_ENCODING to ON when we are ready
option(ENABLE_NEW_ENCODING "enable new encoding (#1033) for storing 64bit size and expire time in milliseconds" OFF)
Expand Down Expand Up @@ -127,7 +128,11 @@ include(cmake/lz4.cmake)
include(cmake/zlib.cmake)
include(cmake/zstd.cmake)
include(cmake/tbb.cmake)
if(ENABLE_SPEEDB)
include(cmake/speedb.cmake)
else()
include(cmake/rocksdb.cmake)
endif()
include(cmake/libevent.cmake)
include(cmake/fmt.cmake)
include(cmake/jsoncons.cmake)
Expand Down
1 change: 1 addition & 0 deletions cmake/modules/FindJeMalloc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ if(jemalloc_SOURCE_DIR)

add_library(JeMalloc::JeMalloc ALIAS jemalloc) # rocksdb use it
install(TARGETS jemalloc EXPORT RocksDBTargets) # export for install(...)
install(TARGETS jemalloc EXPORT SpeedbTargets) # export for install(...)
endif()
1 change: 1 addition & 0 deletions cmake/modules/FindZLIB.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ if(zlib_SOURCE_DIR)
target_link_libraries(zlib_with_headers INTERFACE zlibstatic)
add_library(ZLIB::ZLIB ALIAS zlib_with_headers)
install(TARGETS zlibstatic zlib_with_headers EXPORT RocksDBTargets) # export for install(...)
install(TARGETS zlibstatic zlib_with_headers EXPORT SpeedbTargets) # export for install(...)
endif()
1 change: 1 addition & 0 deletions cmake/modules/Findlz4.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ if(lz4_SOURCE_DIR)

add_library(lz4::lz4 ALIAS lz4) # rocksdb use it
install(TARGETS lz4 EXPORT RocksDBTargets) # export for install(...)
install(TARGETS lz4 EXPORT SpeedbTargets) # export for install(...)
endif()
1 change: 1 addition & 0 deletions cmake/modules/Findzstd.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ if(zstd_SOURCE_DIR)

add_library(zstd::zstd ALIAS zstd) # rocksdb use it
install(TARGETS zstd EXPORT RocksDBTargets) # export for install(...)
install(TARGETS zstd EXPORT SpeedbTargets) # export for install(...)
endif()
60 changes: 60 additions & 0 deletions cmake/speedb.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

include_guard()

set(COMPILE_WITH_JEMALLOC ON)

if (DISABLE_JEMALLOC)
set(COMPILE_WITH_JEMALLOC OFF)
endif()

include(cmake/utils.cmake)

FetchContent_DeclareGitHubWithMirror(speedb
speedb-io/speedb speedb/v2.6.0
MD5=caf1bb6f67c79455a8da3c9986ceacc2
)

FetchContent_GetProperties(jemalloc)
FetchContent_GetProperties(snappy)
FetchContent_GetProperties(tbb)

FetchContent_MakeAvailableWithArgs(speedb
CMAKE_MODULE_PATH=${PROJECT_SOURCE_DIR}/cmake/modules # to locate FindJeMalloc.cmake
Snappy_DIR=${PROJECT_SOURCE_DIR}/cmake/modules # to locate SnappyConfig.cmake
FAIL_ON_WARNINGS=OFF
WITH_TESTS=OFF
WITH_BENCHMARK_TOOLS=OFF
WITH_CORE_TOOLS=OFF
WITH_TOOLS=OFF
WITH_SNAPPY=ON
WITH_LZ4=ON
WITH_ZLIB=ON
WITH_ZSTD=ON
WITH_TOOLS=OFF
WITH_GFLAGS=OFF
WITH_TBB=ON
USE_RTTI=ON
ROCKSDB_BUILD_SHARED=OFF
WITH_JEMALLOC=${COMPILE_WITH_JEMALLOC}
PORTABLE=${PORTABLE}
)

add_library(rocksdb_with_headers INTERFACE)
target_include_directories(rocksdb_with_headers INTERFACE ${speedb_SOURCE_DIR}/include)
target_link_libraries(rocksdb_with_headers INTERFACE speedb)

0 comments on commit 89849e3

Please sign in to comment.