Skip to content

Commit e9b5695

Browse files
authored
Use CMake to build LevelDB (#1542)
1 parent f6a53e1 commit e9b5695

File tree

2 files changed

+27
-48
lines changed

2 files changed

+27
-48
lines changed

Firestore/CMakeLists.txt

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,6 @@ include(cc_rules)
3838
include(podspec_rules)
3939

4040

41-
# External packages
42-
find_package(LevelDB REQUIRED)
43-
find_package(ZLIB)
44-
45-
4641
# Googletest
4742
add_subdirectory(
4843
${FIREBASE_BINARY_DIR}/src/googletest
@@ -61,6 +56,7 @@ add_subdirectory(
6156

6257

6358
# gRPC
59+
find_package(ZLIB)
6460
if(ZLIB_FOUND)
6561
set(gRPC_ZLIB_PROVIDER package CACHE STRING "Use external ZLIB")
6662
endif()
@@ -102,6 +98,19 @@ if(NOT ZLIB_FOUND)
10298
endif()
10399

104100

101+
# LevelDB
102+
set(LEVELDB_BUILD_TESTS OFF CACHE BOOL "Firestore disabled")
103+
set(LEVELDB_BUILD_BENCHMARKS OFF CACHE BOOL "Firestore disabled")
104+
set(LEVELDB_INSTALL OFF CACHE BOOL "Firestore disabled")
105+
add_subdirectory(
106+
${FIREBASE_BINARY_DIR}/src/leveldb
107+
${FIREBASE_BINARY_DIR}/src/leveldb-build
108+
EXCLUDE_FROM_ALL
109+
)
110+
111+
add_alias(LevelDB::LevelDB leveldb)
112+
113+
105114
# nanopb
106115
set(nanopb_BUILD_GENERATOR ON CACHE BOOL "Enable the nanopb generator")
107116
set(nanopb_PROTOC_PATH ${NANOPB_PROTOC_BIN} CACHE STRING "Protoc location")

cmake/external/leveldb.cmake

Lines changed: 13 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -18,60 +18,30 @@ if(TARGET leveldb)
1818
return()
1919
endif()
2020

21-
if(WIN32 OR LEVELDB_ROOT)
22-
# If the user has supplied a LEVELDB_ROOT then just use it. Add an empty
23-
# custom target so that the superbuild depdendencies don't all have to be
24-
# conditional.
21+
if(WIN32)
22+
# Unfortunately, LevelDB does not build on Windows (yet). See:
2523
#
26-
# Also, unfortunately, LevelDB does not build on Windows (yet)
27-
# See:
28-
# https://github.com/google/leveldb/issues/363
29-
# https://github.com/google/leveldb/issues/466
24+
# * https://github.com/google/leveldb/issues/363
25+
# * https://github.com/google/leveldb/issues/466
3026
add_custom_target(leveldb)
3127
return()
3228
endif()
3329

34-
35-
# Clean up warning output to reduce noise in the build
36-
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
37-
set(
38-
LEVELDB_CXX_FLAGS "\
39-
-Wno-deprecated-declarations"
40-
)
41-
endif()
42-
43-
# Map CMake compiler configuration down onto the leveldb Makefile
44-
set(
45-
LEVELDB_OPT "\
46-
$<$<CONFIG:Debug>:${CMAKE_CXX_FLAGS_DEBUG}> \
47-
$<$<CONFIG:Release>:${CMAKE_CXX_FLAGS_RELEASE}>"
48-
)
30+
# CMake support was added after the 1.20 release
31+
set(commit 6caf73ad9dae0ee91873bcb39554537b85163770) # master@{2018-07-14}
4932

5033
ExternalProject_Add(
5134
leveldb
5235

5336
DOWNLOAD_DIR ${FIREBASE_DOWNLOAD_DIR}
54-
DOWNLOAD_NAME leveldb-v1.20.tar.gz
55-
URL https://github.com/google/leveldb/archive/v1.20.tar.gz
56-
URL_HASH SHA256=f5abe8b5b209c2f36560b75f32ce61412f39a2922f7045ae764a2c23335b6664
37+
DOWNLOAD_NAME leveldb-${commit}.tar.gz
38+
URL https://github.com/google/leveldb/archive/${commit}.tar.gz
39+
URL_HASH SHA256=255e3283556aff81e337a951c5f5579f5b98b63d5f345db9e97a1f7563f54f9e
5740

58-
PREFIX ${FIREBASE_BINARY_DIR}
41+
PREFIX ${PROJECT_BINARY_DIR}
5942

60-
# LevelDB's configuration is done in the Makefile
6143
CONFIGURE_COMMAND ""
62-
63-
# The Makefile-based build of leveldb does not support building
64-
# out-of-source.
65-
BUILD_IN_SOURCE ON
66-
67-
# Only build the leveldb library skipping the tools and in-memory
68-
# implementation we don't use.
69-
BUILD_COMMAND
70-
env CXXFLAGS=${LEVELDB_CXX_FLAGS} OPT=${LEVELDB_OPT}
71-
make -j out-static/libleveldb.a
72-
73-
INSTALL_DIR ${FIREBASE_INSTALL_DIR}
74-
75-
INSTALL_COMMAND ""
76-
TEST_COMMAND ""
44+
BUILD_COMMAND ""
45+
INSTALL_COMMAND ""
46+
TEST_COMMAND ""
7747
)

0 commit comments

Comments
 (0)