From eef8f49af0abc75cd5fe8325ae252b5768a74732 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Thu, 14 Oct 2021 17:22:59 +0800 Subject: [PATCH] refact --- CMakeLists.txt | 6 +----- cmake/cmake.options | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 5 deletions(-) create mode 100644 cmake/cmake.options diff --git a/CMakeLists.txt b/CMakeLists.txt index e1b578e08f..abb39c310a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,7 @@ project( # DEPENDENCIES # ============================================================================ set(CMAKE_SUPPORT_DIR "${CMAKE_SOURCE_DIR}/cmake") +include(${CMAKE_SUPPORT_DIR}/cmake.options) function(cat IN_FILE OUT_FILE) file(READ ${IN_FILE} CONTENTS) @@ -20,8 +21,6 @@ set(DEPS_TMP_FILE "${CMAKE_BINARY_DIR}/deps_tmp_CMakeLists.txt.in") configure_file("${CMAKE_SUPPORT_DIR}/deps_CMakeLists.txt.in" ${DEPS_TMP_FILE}) ## googletest -option(BUILD_TEST "If build unit tests using googletest" ON) - if(${BUILD_TEST}) cat("${CMAKE_SUPPORT_DIR}/gtest_CMakeLists.txt.in" ${DEPS_TMP_FILE}) endif(${BUILD_TEST}) @@ -36,20 +35,17 @@ cat("${CMAKE_SUPPORT_DIR}/zlib_CMakeLists.txt.in" ${DEPS_TMP_FILE}) cat("${CMAKE_SUPPORT_DIR}/cjson_CMakeLists.txt.in" ${DEPS_TMP_FILE}) ## leveldb -option(BUILD_WITH_LEVELDB "If build with leveldb" OFF) if(${BUILD_WITH_LEVELDB}) cat("${CMAKE_SUPPORT_DIR}/leveldb_CMakeLists.txt.in" ${DEPS_TMP_FILE}) endif(${BUILD_WITH_LEVELDB}) ## rocksdb -option(BUILD_WITH_ROCKSDB "If build with rocksdb" OFF) if(${BUILD_WITH_ROCKSDB}) cat("${CMAKE_SUPPORT_DIR}/rocksdb_CMakeLists.txt.in" ${DEPS_TMP_FILE}) add_definitions(-DUSE_ROCKSDB) endif(${BUILD_WITH_ROCKSDB}) ## lucene -option(BUILD_WITH_LUCENE "If build with lucene" OFF) if(${BUILD_WITH_LUCENE}) cat("${CMAKE_SUPPORT_DIR}/lucene_CMakeLists.txt.in" ${DEPS_TMP_FILE}) endif(${BUILD_WITH_LUCENE}) diff --git a/cmake/cmake.options b/cmake/cmake.options new file mode 100644 index 0000000000..bc3177e5cc --- /dev/null +++ b/cmake/cmake.options @@ -0,0 +1,26 @@ +# ========================================================= +# Deps options +# ========================================================= +option( + BUILD_TEST + "If build unit tests using googletest" + ON +) + +option( + BUILD_WITH_LEVELDB + "If build with leveldb" + OFF +) + +option( + BUILD_WITH_ROCKSDB + "If build with rocksdb" + OFF +) + +option( + BUILD_WITH_LUCENE + "If build with lucene" + OFF +) \ No newline at end of file -- GitLab