Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support ninja build,reduced dependency #178

Open
wants to merge 4 commits into
base: unstable
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,18 @@ ELSE ()
SET(LIB_SUFFIX "deps-debug")
ENDIF ()

IF(CMAKE_GENERATOR STREQUAL "Ninja")
MESSAGE(STATUS "Ninja generator is being used.")
SET (EXTERNAL_GENERATOR "-G Ninja")
SET (EXTERNAL_BUILD "ninja")
elseif (CMAKE_GENERATOR STREQUAL "Unix Makefiles")
MESSAGE(STATUS "Unix Makefiles generator is being used.")
SET (EXTERNAL_GENERATOR "-GUnix Makefiles")
SET (EXTERNAL_BUILD "make")
else ()
MESSAGE(FATAL_ERROR "only support Ninja or Unix Makefiles")
ENDIF()

SET_PROPERTY(DIRECTORY PROPERTY EP_BASE ${CMAKE_CURRENT_SOURCE_DIR}/${EP_BASE_SUFFIX})
SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/modules/")
SET(BUILD_SUPPORT_DIR ${PROJECT_SOURCE_DIR}/build_support)
Expand Down
14 changes: 5 additions & 9 deletions cmake/braft.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

INCLUDE(ExternalProject)

SET(BRAFT_SOURCES_DIR "${LIB_SOURCE_DIR}/extern_braft" CACHE PATH "Path to braft sources")
SET(BRAFT_SOURCES_DIR "${LIB_SOURCE_DIR}/braft" CACHE PATH "Path to braft sources")
SET(BRAFT_INSTALL_DIR ${LIB_INSTALL_PREFIX})
SET(BRAFT_INCLUDE_DIR "${LIB_INCLUDE_DIR}" CACHE PATH "brpc include directory." FORCE)
SET(BRAFT_LIBRARIES "${LIB_INSTALL_DIR}/libbraft.a" CACHE FILEPATH "brpc library." FORCE)
Expand All @@ -17,7 +17,7 @@ ELSE ()
ENDIF ()

ExternalProject_Add(
extern_braft
braft
${EXTERNAL_PROJECT_LOG_ARGS}
DEPENDS brpc
GIT_REPOSITORY "https://github.com/arana-db/braft.git"
Expand Down Expand Up @@ -51,11 +51,7 @@ ExternalProject_Add(
-DPROTOBUF_PROTOC_EXECUTABLE=${PROTOBUF_PROTOC}
-DOPENSSL_INCLUDE_DIR=${OPENSSL_INCLUDE_DIR}
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
BUILD_COMMAND make -j${CPU_CORE}
UPDATE_COMMAND ""
${EXTERNAL_GENERATOR}
BUILD_COMMAND ${EXTERNAL_BUILD} -j${CPU_CORE}
BUILD_BYPRODUCTS ${BRAFT_LIBRARIES}
)

ADD_DEPENDENCIES(extern_braft brpc gflags)
ADD_LIBRARY(braft STATIC IMPORTED GLOBAL)
SET_PROPERTY(TARGET braft PROPERTY IMPORTED_LOCATION ${BRAFT_LIBRARIES})
ADD_DEPENDENCIES(braft extern_braft)
13 changes: 5 additions & 8 deletions cmake/brpc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory.

SET(BRPC_SOURCES_DIR "${LIB_SOURCE_DIR}/extern_brpc" CACHE PATH "Path to brpc sources")
SET(BRPC_SOURCES_DIR "${LIB_SOURCE_DIR}/brpc" CACHE PATH "Path to brpc sources")
SET(BRPC_INSTALL_DIR ${LIB_INSTALL_PREFIX})
SET(BRPC_INCLUDE_DIR "${LIB_INCLUDE_DIR}" CACHE PATH "brpc include directory." FORCE)
SET(BRPC_LIBRARIES "${LIB_INSTALL_DIR}/libbrpc.a" CACHE FILEPATH "brpc library." FORCE)
Expand All @@ -14,7 +14,7 @@ SET(CMAKE_FIND_LIBRARY_SUFFIXES ${LIB_INSTALL_PREFIX})
SET(CMAKE_CPP_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
# If minimal .a is need, you can set WITH_DEBUG_SYMBOLS=OFF
ExternalProject_Add(
extern_brpc
brpc
${EXTERNAL_PROJECT_LOG_ARGS}
DEPENDS ssl crypto zlib protobuf leveldb gflags
URL https://github.com/apache/brpc/archive/refs/tags/1.8.0.tar.gz
Expand Down Expand Up @@ -54,10 +54,7 @@ ExternalProject_Add(
-DPROJECT_BINARY_DIR=${LIB_INSTALL_PREFIX}
-DWITH_GLOG=OFF
-DDOWNLOAD_GTEST=OFF
BUILD_COMMAND make -j${CPU_CORE}
UPDATE_COMMAND ""
${EXTERNAL_GENERATOR}
BUILD_COMMAND ${EXTERNAL_BUILD} -j${CPU_CORE}
BUILD_BYPRODUCTS ${BRPC_LIBRARIES}
)
ADD_DEPENDENCIES(extern_brpc ssl crypto zlib protobuf leveldb gflags)
ADD_LIBRARY(brpc STATIC IMPORTED GLOBAL)
SET_PROPERTY(TARGET brpc PROPERTY IMPORTED_LOCATION ${BRPC_LIBRARIES})
ADD_DEPENDENCIES(brpc extern_brpc)
13 changes: 5 additions & 8 deletions cmake/fmt.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ ELSE ()
SET(LIB_FMT libfmt.a)
ENDIF ()

SET(FMT_SOURCES_DIR "${LIB_SOURCE_DIR}/extern_fmt" CACHE PATH "Path to fmt sources")
SET(FMT_SOURCES_DIR "${LIB_SOURCE_DIR}/fmt" CACHE PATH "Path to fmt sources")
SET(FMT_INCLUDE_DIR "${LIB_INCLUDE_DIR}" CACHE PATH "fmt include directory." FORCE)
SET(FMT_LIBRARIES "${LIB_INSTALL_DIR}/${LIB_FMT}" CACHE FILEPATH "fmt library directory." FORCE)

ExternalProject_Add(
extern_fmt
fmt
URL https://github.com/fmtlib/fmt/archive/10.1.1.zip
URL_HASH SHA256=3c2e73019178ad72b0614a3124f25de454b9ca3a1afe81d5447b8d3cbdb6d322
DOWNLOAD_NO_PROGRESS 1
Expand All @@ -33,11 +33,8 @@ ExternalProject_Add(
-DFMT_DOC=FALSE
-DFMT_TEST=FALSE
-DSHARED_LIBS=FALSE
BUILD_COMMAND make -j${CPU_CORE}
${EXTERNAL_GENERATOR}
BUILD_BYPRODUCTS ${FMT_LIBRARIES}
BUILD_COMMAND ${EXTERNAL_BUILD} -j${CPU_CORE}
UPDATE_COMMAND ""
)


ADD_LIBRARY(fmt STATIC IMPORTED GLOBAL)
SET_PROPERTY(TARGET fmt PROPERTY IMPORTED_LOCATION ${FMT_LIBRARIES})
ADD_DEPENDENCIES(fmt extern_fmt)
14 changes: 5 additions & 9 deletions cmake/gflags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,21 @@ ELSE ()
SET(LIB_GFLAGS libgflags.a)
ENDIF ()

SET(GFLAGS_SOURCES_DIR "${LIB_SOURCE_DIR}/extern_gflags" CACHE PATH "Path to gflags sources")
SET(GFLAGS_SOURCES_DIR "${LIB_SOURCE_DIR}/gflags" CACHE PATH "Path to gflags sources")
SET(GFLAGS_INCLUDE_DIR ${LIB_INCLUDE_DIR} CACHE PATH "gflags include directory." FORCE)
SET(GFLAGS_LIBRARIES ${LIB_INSTALL_DIR}/${LIB_GFLAGS} CACHE FILEPATH "gflags library." FORCE)
SET(GFLAGS_LIBRARY ${LIB_INSTALL_DIR}/${LIB_GFLAGS} CACHE FILEPATH "gflags library." FORCE)

# SET(GFLAGS_INCLUDE_PATH "${LIB_INCLUDE_DIR}/gflags" CACHE PATH "gflags include directory." FORCE)

ExternalProject_Add(
extern_gflags
gflags
URL https://github.com/gflags/gflags/archive/v2.2.2.zip
URL_HASH SHA256=19713a36c9f32b33df59d1c79b4958434cb005b5b47dc5400a7a4b078111d9b5
DOWNLOAD_NO_PROGRESS 1
DOWNLOAD_DIR "${CMAKE_CURRENT_SOURCE_DIR}/download"
DOWNLOAD_NAME "gflags-2.2.2.zip"
SOURCE_DIR ${GFLAGS_SOURCES_DIR}
CMAKE_ARGS
${EXTERNAL_GENERATOR}
${EXTERNAL_PROJECT_C}
${EXTERNAL_PROJECT_CXX}
${EXTERNAL_PROJECT_CXX_FLAGS}
Expand All @@ -39,10 +38,7 @@ ExternalProject_Add(
-DGFLAGS_NAMESPACE=gflags
-DGFLAGS_BUILD_TESTING=OFF
-DCMAKE_INSTALL_PREFIX=${LIB_INSTALL_PREFIX}
BUILD_COMMAND make -j${CPU_CORE}
BUILD_COMMAND ${EXTERNAL_BUILD} -j${CPU_CORE}
UPDATE_COMMAND ""
BUILD_BYPRODUCTS ${GFLAGS_LIBRARY}
)

ADD_LIBRARY(gflags STATIC IMPORTED GLOBAL)
SET_PROPERTY(TARGET gflags PROPERTY IMPORTED_LOCATION ${GFLAGS_LIBRARIES})
ADD_DEPENDENCIES(gflags extern_gflags)
14 changes: 5 additions & 9 deletions cmake/gtest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,27 @@
# LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory.

SET(GTEST_SOURCES_DIR "${LIB_SOURCE_DIR}/extern_gtest" CACHE PATH "Path to gtest sources")
SET(GTEST_SOURCES_DIR "${LIB_SOURCE_DIR}/gtest" CACHE PATH "Path to gtest sources")
SET(GTEST_INCLUDE_DIR "${LIB_INCLUDE_DIR}" CACHE PATH "gtest include directory." FORCE)
SET(GTEST_LIBRARIES "${LIB_INSTALL_DIR}/libgtest.a" CACHE FILEPATH "gtest lib directory." FORCE)
SET(GTEST_MAIN_LIBRARIES "${LIB_INSTALL_DIR}/libgtest_main.a" CACHE FILEPATH "gtest main include directory." FORCE)
SET(GMOCK_LIBRARIES "${LIB_INSTALL_DIR}/libgmock.a" CACHE FILEPATH "gmock directory." FORCE)

ExternalProject_Add(
extern_gtest
gtest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG v1.14.0
GIT_SHALLOW true
SOURCE_DIR ${GTEST_SOURCES_DIR}
CMAKE_ARGS
${EXTERNAL_GENERATOR}
-DCMAKE_INSTALL_PREFIX=${LIB_INSTALL_PREFIX}
-DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
${EXTERNAL_PROJECT_C}
${EXTERNAL_PROJECT_CXX}
${EXTERNAL_PROJECT_CXX_FLAGS}
${EXTERNAL_PROJECT_CXX_LINK_FLAGS}
BUILD_COMMAND ${EXTERNAL_BUILD} -j${CPU_CORE}
BUILD_BYPRODUCTS ${GTEST_LIBRARIES}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add missing BUILD_BYPRODUCTS.

The BUILD_BYPRODUCTS should include all built libraries to properly support Ninja build system.

-        BUILD_BYPRODUCTS ${GTEST_LIBRARIES}
+        BUILD_BYPRODUCTS ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES} ${GMOCK_LIBRARIES}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
BUILD_BYPRODUCTS ${GTEST_LIBRARIES}
BUILD_BYPRODUCTS ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES} ${GMOCK_LIBRARIES}

)

ADD_DEPENDENCIES(extern_gtest snappy gflags zlib)
ADD_LIBRARY(gtest STATIC IMPORTED GLOBAL)
ADD_LIBRARY(gtest_main STATIC IMPORTED GLOBAL)
SET_PROPERTY(TARGET gtest PROPERTY IMPORTED_LOCATION ${GTEST_LIBRARIES})
SET_PROPERTY(TARGET gtest_main PROPERTY IMPORTED_LOCATION ${GTEST_MAIN_LIBRARIES})
ADD_DEPENDENCIES(gtest extern_gtest)
13 changes: 5 additions & 8 deletions cmake/leveldb.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
# LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory.

SET(LEVELDB_SOURCES_DIR "${LIB_SOURCE_DIR}/extern_leveldb" CACHE PATH "Path to leveldb sources")
SET(LEVELDB_SOURCES_DIR "${LIB_SOURCE_DIR}/leveldb" CACHE PATH "Path to leveldb sources")
SET(LEVELDB_INCLUDE_DIR "${LIB_INCLUDE_DIR}/leveldb" CACHE PATH "leveldb include directory." FORCE)
SET(LEVELDB_LIBRARIES "${LIB_INSTALL_DIR}/libleveldb.a" CACHE FILEPATH "leveldb include directory." FORCE)
SET(LEVELDB_INSTALL_LIBDIR "${LIB_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")

ExternalProject_Add(
extern_leveldb
leveldb
${EXTERNAL_PROJECT_LOG_ARGS}
DEPENDS snappy
GIT_REPOSITORY "https://github.com/google/leveldb.git"
Expand All @@ -31,11 +31,8 @@ ExternalProject_Add(
-DLEVELDB_BUILD_TESTS=OFF
-DLEVELDB_BUILD_BENCHMARKS=OFF
-DCMAKE_BUILD_TYPE=${THIRD_PARTY_BUILD_TYPE}
BUILD_COMMAND make -j${CPU_CORE}
${EXTERNAL_GENERATOR}
BUILD_COMMAND ${EXTERNAL_BUILD} -j${CPU_CORE}
UPDATE_COMMAND ""
BUILD_BYPRODUCTS ${LEVELDB_LIBRARIES}
)

ADD_DEPENDENCIES(extern_leveldb snappy)
ADD_LIBRARY(leveldb STATIC IMPORTED GLOBAL)
SET_PROPERTY(TARGET leveldb PROPERTY IMPORTED_LOCATION ${LEVELDB_LIBRARIES})
ADD_DEPENDENCIES(leveldb extern_leveldb)
12 changes: 5 additions & 7 deletions cmake/lz4.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
# LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory.

SET(LZ4_SOURCES_DIR "${LIB_SOURCE_DIR}/extern_lz4" CACHE PATH "Path to lz4 sources")
SET(LZ4_SOURCES_DIR "${LIB_SOURCE_DIR}/lz4" CACHE PATH "Path to lz4 sources")
SET(LZ4_INCLUDE_DIR "${LIB_INCLUDE_DIR}" CACHE PATH "lz4 include directory." FORCE)
SET(LZ4_LIBRARIES "${LIB_INSTALL_DIR}/liblz4.a" CACHE FILEPATH "lz4 include directory." FORCE)

ExternalProject_Add(
extern_lz4
lz4
URL https://github.com/lz4/lz4/archive/refs/tags/v1.9.4.tar.gz
URL_HASH SHA256=0b0e3aa07c8c063ddf40b082bdf7e37a1562bda40a0ff5272957f3e987e0e54b
DOWNLOAD_DIR "${CMAKE_CURRENT_SOURCE_DIR}/download"
Expand All @@ -28,10 +28,8 @@ ExternalProject_Add(
-DBUILD_TESTING=OFF
-DBUILD_STATIC_LIBS=ON
-DBUILD_SHARED_LIBS=OFF
BUILD_COMMAND make -j${CPU_CORE}
${EXTERNAL_GENERATOR}
BUILD_COMMAND ${EXTERNAL_BUILD} -j${CPU_CORE}
UPDATE_COMMAND ""
BUILD_BYPRODUCTS ${LZ4_LIBRARIES}
)

ADD_LIBRARY(lz4 STATIC IMPORTED GLOBAL)
SET_PROPERTY(TARGET lz4 PROPERTY IMPORTED_LOCATION ${LZ4_LIBRARIES})
ADD_DEPENDENCIES(lz4 extern_lz4)
14 changes: 6 additions & 8 deletions cmake/openssl.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
# LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory.

SET(OPENSSL_SOURCE_DIR "${LIB_SOURCE_DIR}/extern_openssl" CACHE PATH "Path to OpenSSL sources")
SET(OPENSSL_SOURCE_DIR "${LIB_SOURCE_DIR}/openssl" CACHE PATH "Path to OpenSSL sources")
SET(OPENSSL_INSTALL_DIR "${LIB_INSTALL_PREFIX}")
SET(OPENSSL_INCLUDE_DIR "${LIB_INCLUDE_DIR}" CACHE PATH "Openssl include directory." FORCE)
SET(OPENSSL_LIB "lib")
SET(OPENSSL_SSL_LIBRARY "${OPENSSL_INSTALL_DIR}/${OPENSSL_LIB}/libssl.a")
SET(OPENSSL_CRYPTO_LIBRARY "${OPENSSL_INSTALL_DIR}/${OPENSSL_LIB}/libcrypto.a")

FILE(MAKE_DIRECTORY ${OPENSSL_INCLUDE_DIR})

Expand Down Expand Up @@ -40,20 +43,15 @@ ExternalProject_Add(
INSTALL_COMMAND make install_sw
INSTALL_DIR ${OPENSSL_INSTALL_DIR}
UPDATE_COMMAND ""
BUILD_BYPRODUCTS ${OPENSSL_SSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY}
)

SET(OPENSSL_LIB "lib")
ADD_LIBRARY(ssl STATIC IMPORTED GLOBAL)
SET_PROPERTY(TARGET ssl PROPERTY IMPORTED_LOCATION ${OPENSSL_INSTALL_DIR}/${OPENSSL_LIB}/libssl.a)
SET_PROPERTY(TARGET ssl PROPERTY IMPORTED_LOCATION ${OPENSSL_SSL_LIBRARY})
SET_PROPERTY(TARGET ssl PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${OPENSSL_INCLUDE_DIR})
ADD_DEPENDENCIES(ssl OpenSSL)
SET(OPENSSL_SSL_LIBRARY ${OPENSSL_INSTALL_DIR}/${OPENSSL_LIB}/libssl.a)
list(APPEND LIBS ssl)

ADD_LIBRARY(crypto STATIC IMPORTED GLOBAL)
SET_PROPERTY(TARGET crypto PROPERTY IMPORTED_LOCATION ${OPENSSL_INSTALL_DIR}/${OPENSSL_LIB}/libcrypto.a)
SET_PROPERTY(TARGET crypto PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${OPENSSL_INCLUDE_DIR})
ADD_DEPENDENCIES(crypto OpenSSL)
SET(OPENSSL_CRYPTO_LIBRARY ${OPENSSL_INSTALL_DIR}/${OPENSSL_LIB}/libcrypto.a)

SET(OPENSSL_INCLUDE_DIR ${LIB_INCLUDE_DIR})
12 changes: 5 additions & 7 deletions cmake/protobuf.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ ELSE ()
SET(LIB_PROTOC "libprotoc.a")
ENDIF ()

SET(PROTOBUF_SOURCES_DIR "${LIB_SOURCE_DIR}/extern_protobuf" CACHE PATH "Path to protobuf sources")
SET(PROTOBUF_SOURCES_DIR "${LIB_SOURCE_DIR}/protobuf" CACHE PATH "Path to protobuf sources")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add missing BUILD_BYPRODUCTS for protoc library.

While the build system improvements look good, the BUILD_BYPRODUCTS should include both the protobuf and protoc libraries since both are built by this target.

Update the BUILD_BYPRODUCTS line:

-        BUILD_BYPRODUCTS ${LIB_PROTOBUF}
+        BUILD_BYPRODUCTS ${PROTOBUF_LIBRARY} ${PROTOC_LIBRARY}

Also applies to: 23-23, 48-50

SET(PROTOBUF_INCLUDE_DIR "${LIB_INCLUDE_DIR}" CACHE PATH "protobuf include directory." FORCE)
SET(PROTOBUF_LIBRARY "${LIB_INSTALL_DIR}/${LIB_PROTOBUF}" CACHE FILEPATH "protobuf install directory." FORCE)
SET(PROTOC_LIBRARY "${LIB_INSTALL_DIR}/${LIB_PROTOC}" CACHE FILEPATH "protoc install directory." FORCE)
SET(PROTOBUF_PROTOC "${LIB_INSTALL_PREFIX}/bin/protoc")

ExternalProject_Add(
extern_protobuf
protobuf
UPDATE_COMMAND ""
LOG_CONFIGURE 1
LOG_BUILD 1
Expand All @@ -45,9 +45,7 @@ ExternalProject_Add(
-DBUILD_SHARED_LIBS=OFF
-Dprotobuf_BUILD_TESTS=OFF
-Dprotobuf_BUILD_LIBPROTOC=ON
BUILD_COMMAND make -j${CPU_CORE}
${EXTERNAL_GENERATOR}
BUILD_COMMAND ${EXTERNAL_BUILD} -j${CPU_CORE}
BUILD_BYPRODUCTS ${LIB_PROTOBUF}
)

ADD_LIBRARY(protobuf STATIC IMPORTED GLOBAL)
SET_PROPERTY(TARGET protobuf PROPERTY IMPORTED_LOCATION ${PROTOBUF_LIBRARY})
ADD_DEPENDENCIES(protobuf extern_protobuf)
13 changes: 5 additions & 8 deletions cmake/rocksdb.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
# LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory.

SET(ROCKSDB_SOURCES_DIR "${LIB_SOURCE_DIR}/extern_rocksdb" CACHE PATH "Path to RocksDB sources")
SET(ROCKSDB_SOURCES_DIR "${LIB_SOURCE_DIR}/rocksdb" CACHE PATH "Path to RocksDB sources")
SET(ROCKSDB_INCLUDE_DIR "${LIB_INCLUDE_DIR}" CACHE PATH "rocksdb include directory." FORCE)
SET(ROCKSDB_LIBRARIES "${LIB_INSTALL_DIR}/librocksdb.a" CACHE FILEPATH "rocksdb include directory." FORCE)

ExternalProject_Add(
extern_rocksdb
rocksdb
${EXTERNAL_PROJECT_LOG_ARGS}
DEPENDS gflags snappy zlib lz4 zstd
GIT_REPOSITORY https://github.com/facebook/rocksdb.git
Expand Down Expand Up @@ -41,11 +41,8 @@ ExternalProject_Add(
-DWITH_ZSTD=ON
-DWITH_GFLAGS=ON
-DUSE_RTTI=ON
BUILD_COMMAND make -j${CPU_CORE}
${EXTERNAL_GENERATOR}
BUILD_COMMAND ${EXTERNAL_BUILD} -j${CPU_CORE}
UPDATE_COMMAND ""
BUILD_BYPRODUCTS ${ROCKSDB_LIBRARIES}
)

ADD_DEPENDENCIES(extern_rocksdb snappy gflags zlib lz4)
ADD_LIBRARY(rocksdb STATIC IMPORTED GLOBAL)
SET_PROPERTY(TARGET rocksdb PROPERTY IMPORTED_LOCATION ${ROCKSDB_LIBRARIES})
ADD_DEPENDENCIES(rocksdb extern_rocksdb)
12 changes: 5 additions & 7 deletions cmake/snappy.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
# LICENSE file in the root directory of this source tree. An additional grant
# of patent rights can be found in the PATENTS file in the same directory.

SET(Snappy_SOURCES_DIR "${LIB_SOURCE_DIR}/extern_snappy" CACHE PATH "Path to snappy sources")
SET(Snappy_SOURCES_DIR "${LIB_SOURCE_DIR}/snappy" CACHE PATH "Path to snappy sources")
SET(Snappy_INCLUDE_DIRS "${LIB_INCLUDE_DIR}" CACHE PATH "Snappy include directory." FORCE)
SET(Snappy_LIBRARIES "${LIB_INSTALL_DIR}/libsnappy.a" CACHE FILEPATH "Snappy install directory." FORCE)

ExternalProject_Add(
extern_snappy
snappy
${EXTERNAL_PROJECT_LOG_ARGS}
GIT_REPOSITORY "https://github.com/google/snappy.git"
GIT_TAG "1.2.1"
Expand All @@ -26,9 +26,7 @@ ExternalProject_Add(
-DSNAPPY_BUILD_BENCHMARKS=OFF
-DBUILD_STATIC_LIBS=ON
-DBUILD_SHARED_LIBS=OFF
UPDATE_COMMAND ""
${EXTERNAL_GENERATOR}
BUILD_COMMAND ${EXTERNAL_BUILD} -j${CPU_CORE}
BUILD_BYPRODUCTS ${Snappy_LIBRARIES}
)

ADD_LIBRARY(snappy STATIC IMPORTED GLOBAL)
SET_PROPERTY(TARGET snappy PROPERTY IMPORTED_LOCATION ${Snappy_LIBRARIES})
ADD_DEPENDENCIES(snappy extern_snappy)
Loading
Loading