1 Star 0 Fork 225

hongyangliu/distributeddatamgr_kv_store

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
CMakeLists.txt 11.92 KB
一键复制 编辑 原始数据 按行查看 历史
cmake_minimum_required(VERSION 3.2)
project(distributed_ut VERSION 1.0.0)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -std=c++17 -pthread")
add_compile_options(-Werror=sign-compare -Werror=unused-variable)
add_compile_options(-Wno-conversion-null)
add_compile_options(-Wuninitialized)
add_compile_options(-Wformat)
add_compile_options(-Wno-deprecated-declarations)
set(THIRD_PARTY_DIR "${PROJECT_SOURCE_DIR}/third_party")
# Address Sanitizer
option(USE_ASAN "Compile with address sanitiser" OFF)
if (USE_ASAN)
message(STATUS "Compile with address sanitiser ${USE_ASAN}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer -O1")
endif()
function(download_repo repo_name repo_branch repo_url)
execute_process(
COMMAND [ -d ${repo_name} ]
WORKING_DIRECTORY ${THIRD_PARTY_DIR}
RESULT_VARIABLE REPO_EXISTS
)
message(STATUS "check ${repo_name} exists result: ${REPO_EXISTS}")
if (NOT (${REPO_EXISTS} EQUAL 0))
message(STATUS "Downloading ${repo_name} from ${repo_url}")
separate_arguments(repo_url)
execute_process(
COMMAND git clone ${repo_url} -b ${repo_branch}
WORKING_DIRECTORY ${THIRD_PARTY_DIR}
)
message(STATUS "Download ${repo_name} finished")
endif()
endfunction(download_repo)
# create third_party directory
execute_process(
COMMAND mkdir -p ${THIRD_PARTY_DIR}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
)
# Download dependencies
download_repo("third_party_jsoncpp" "master" "https://gitee.com/openharmony/third_party_jsoncpp.git")
download_repo("third_party_googletest" "master" "https://gitee.com/openharmony/third_party_googletest.git")
download_repo("third_party_openssl" "master" "https://gitee.com/openharmony/third_party_openssl.git")
download_repo("third_party_zlib" "master" "https://gitee.com/openharmony/third_party_zlib.git")
download_repo("third_party_sqlite" "master" "https://gitee.com/openharmony/third_party_sqlite.git")
download_repo("utils_native" "master" "https://gitee.com/openharmony/utils_native.git")
download_repo("kate" "master" "https://gitee.com/lianhuix/kate.git")
download_repo("third_party_cJSON" "master" "https://gitee.com/openharmony/third_party_cJSON.git")
download_repo("resourceschedule_ffrt" "weekly_20231127" "https://gitee.com/openharmony/resourceschedule_ffrt.git")
function(build_repo repo_name script_path)
execute_process(
COMMAND [ -f ${repo_name}/Makefile ]
WORKING_DIRECTORY ${THIRD_PARTY_DIR}
RESULT_VARIABLE SCRIPT_EXISTS
)
if (NOT (${SCRIPT_EXISTS} EQUAL 0))
message(STATUS "Copy build script ${script_path}/Makefile to repo ${repo_name}")
execute_process(
COMMAND cp third_party/kate/${script_path}/Makefile third_party/${repo_name} -f
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
)
message(STATUS "Build ${repo_name}")
execute_process(
COMMAND make -j9
WORKING_DIRECTORY ${THIRD_PARTY_DIR}/${repo_name}
)
message(STATUS "Build finished")
endif()
endfunction(build_repo)
function(cmake_repo repo_name options)
execute_process(
COMMAND [ -d ${repo_name}/build ]
WORKING_DIRECTORY ${THIRD_PARTY_DIR}
RESULT_VARIABLE BUILD_FINISHED
)
if (NOT (${BUILD_FINISHED} EQUAL 0))
message(STATUS "compile repo ${repo_name}")
execute_process(
COMMAND mkdir -p build
WORKING_DIRECTORY ${THIRD_PARTY_DIR}/${repo_name}
)
execute_process(
COMMAND cmake .. ${options}
WORKING_DIRECTORY ${THIRD_PARTY_DIR}/${repo_name}/build
)
execute_process(
COMMAND make -j9
WORKING_DIRECTORY ${THIRD_PARTY_DIR}/${repo_name}/build
)
endif()
endfunction(cmake_repo)
function(build_openssl repo_name)
execute_process(
COMMAND [ -f Makefile ]
WORKING_DIRECTORY ${THIRD_PARTY_DIR}/${repo_name}
RESULT_VARIABLE BUILD_FINISHED
)
if (NOT (${BUILD_FINISHED} EQUAL 0))
message(STATUS "compile repo ${repo_name}")
execute_process(
COMMAND chmod +x ./config
WORKING_DIRECTORY ${THIRD_PARTY_DIR}/${repo_name}
)
execute_process(
COMMAND ./config
WORKING_DIRECTORY ${THIRD_PARTY_DIR}/${repo_name}
)
execute_process(
COMMAND make -j9
WORKING_DIRECTORY ${THIRD_PARTY_DIR}/${repo_name}
)
endif()
endfunction(build_openssl)
function(build_ffrt repo_name)
execute_process(
COMMAND [ -f Makefile ]
WORKING_DIRECTORY ${THIRD_PARTY_DIR}/${repo_name}
RESULT_VARIABLE BUILD_FINISHED
)
if (NOT (${BUILD_FINISHED} EQUAL 0))
message(STATUS "compile repo ${repo_name}")
execute_process(
COMMAND cmake -DFFRT_EXAMPLE=OFF -DFFRT_CLANG_COMPILE=OFF ./
WORKING_DIRECTORY ${THIRD_PARTY_DIR}/${repo_name}
)
execute_process(
COMMAND make -j9
WORKING_DIRECTORY ${THIRD_PARTY_DIR}/${repo_name}
)
endif()
endfunction(build_ffrt)
# build openssl Makefile
build_openssl("third_party_openssl")
# build securec
build_repo("utils_native" "securec")
# build sqlite
build_repo("third_party_sqlite" "sqlite")
# build jsoncpp
cmake_repo("third_party_jsoncpp" "-DJSONCPP_WITH_TESTS=OFF")
# build zlib
cmake_repo("third_party_zlib" "")
# build cJSON
cmake_repo("third_party_cJSON" "-DENABLE_CJSON_TEST=OFF")
# build ffrt
build_ffrt("resourceschedule_ffrt")
#build googletest
execute_process(
COMMAND sed -i /Wshadow/d internal_utils.cmake
WORKING_DIRECTORY ${THIRD_PARTY_DIR}/third_party_googletest/googletest/cmake
)
execute_process(
COMMAND sed -i "s%testing::GTEST_FLAG(output)%// testing::GTEST_FLAG(output)%g" googlemock/src/gmock_main.cc
WORKING_DIRECTORY ${THIRD_PARTY_DIR}/third_party_googletest
)
execute_process(
COMMAND sed -i "s%testing::GTEST_FLAG(output)%// testing::GTEST_FLAG(output)%g" googletest/src/gtest_main.cc
WORKING_DIRECTORY ${THIRD_PARTY_DIR}/third_party_googletest
)
cmake_repo("third_party_googletest" "")
# add_definitions(-Wno-format)
add_definitions(-DSQLITE_ENABLE_SNAPSHOT)
add_definitions(-D_LARGEFILE64_SOURCE)
add_definitions(-D_FILE_OFFSET_BITS=64)
add_definitions(-DSQLITE_HAS_CODEC)
add_definitions(-DSQLITE_ENABLE_JSON1)
add_definitions(-DUSING_HILOG_LOGGER)
# add_definitions(-DUSE_SQLITE_SYMBOLS)
add_definitions(-DUSING_DB_JSON_EXTRACT_AUTOMATICALLY)
add_definitions(-DJSONCPP_USE_BUILDER)
add_definitions(-DOMIT_FLATBUFFER)
add_definitions(-DUSE_PRINT)
add_definitions(-DRELATIONAL_STORE)
add_definitions(-DMANNUAL_SYNC_AND_CLEAN_CLOUD_DATA)
# add_definitions(-DSQLITE3_HW_EXPORT_SYMBOLS)
add_definitions(-DTEST_DB)
add_definitions(-DDB_DEBUG_ENV)
add_definitions(-DTESTCASES_USING_GTEST_EXT)
add_definitions(-DSQLITE_DISTRIBUTE_RELATIONAL)
add_definitions(-DSQLITE_ENABLE_DROPTABLE_CALLBACK)
add_definitions(-DRUNNING_ON_TESTCASE)
add_definitions(-DOMIT_MULTI_VER)
# build cJSON
#cmake_repo("third_party_cJSON" "cJSON")
add_definitions(-DDB_DEBUG_ENV)
find_package(Threads)
enable_testing()
set(DB_PATH ${PROJECT_SOURCE_DIR}/frameworks/libs/distributeddb)
include_directories(
${DB_PATH}/common/include
${DB_PATH}/common/include/relational
${DB_PATH}/common/include/cloud
${DB_PATH}/common/src
${DB_PATH}/common/src/evloop/include
${DB_PATH}/common/src/evloop/src
${DB_PATH}/common/src/cloud
${DB_PATH}/communicator/include
${DB_PATH}/communicator/src
${DB_PATH}/include
${DB_PATH}/interfaces/include
${DB_PATH}/interfaces/include/cloud
${DB_PATH}/interfaces/include/relational
${DB_PATH}/interfaces/src
${DB_PATH}/interfaces/src/relational
${DB_PATH}/storage/include
${DB_PATH}/storage/src
${DB_PATH}/storage/src/multiver
${DB_PATH}/storage/src/operation
${DB_PATH}/storage/src/sqlite
${DB_PATH}/storage/src/naturalbase_lite
${DB_PATH}/storage/src/sqlite/relational
${DB_PATH}/storage/src/sqlite/kv
${DB_PATH}/storage/src/upgrader
${DB_PATH}/storage/src/gaussdb_rd
${DB_PATH}/storage/src/kv
${DB_PATH}/storage/src/relational
${DB_PATH}/syncer/include
${DB_PATH}/syncer/src
${DB_PATH}/syncer/src/cloud
${DB_PATH}/syncer/src/device
${DB_PATH}/syncer/src/device/multiver
${DB_PATH}/syncer/src/device/singlever
${DB_PATH}/test/unittest/common/common
${DB_PATH}/test/unittest/common/communicator
${DB_PATH}/test/unittest/common/interfaces
${DB_PATH}/test/unittest/common/storage
${DB_PATH}/test/unittest/common/syncer
${DB_PATH}/test/unittest/common/syncer/cloud
)
include_directories(
${THIRD_PARTY_DIR}/third_party_cJSON
${THIRD_PARTY_DIR}/third_party_googletest/googletest/include
${THIRD_PARTY_DIR}/third_party_googletest/googlemock/include
${THIRD_PARTY_DIR}/third_party_jsoncpp/include
${THIRD_PARTY_DIR}/third_party_sqlite/include
${THIRD_PARTY_DIR}/utils_native/base/include
${THIRD_PARTY_DIR}/utils_native/base/src/securec
${THIRD_PARTY_DIR}/third_party_openssl/include
${THIRD_PARTY_DIR}/third_party_zlib
${THIRD_PARTY_DIR}/kate/log/include
${THIRD_PARTY_DIR}/resourceschedule_ffrt/interfaces/kits
)
# rd include path
set(GAUSS_RD_DIR "${DB_PATH}/gaussdb_rd")
include_directories(SYSTEM
${GAUSS_RD_DIR}/include
${GAUSS_RD_DIR}/include/grd_base
${GAUSS_RD_DIR}/include/grd_document
${GAUSS_RD_DIR}/include/grd_kv
${GAUSS_RD_DIR}/src/common/include
${GAUSS_RD_DIR}/src/executor/base
${GAUSS_RD_DIR}/src/executor/document
${GAUSS_RD_DIR}/src/executor/include
${GAUSS_RD_DIR}/src/executor/kv
${GAUSS_RD_DIR}/src/interface/include
${GAUSS_RD_DIR}/src/interface/src
${GAUSS_RD_DIR}/src/oh_adapter/include
${GAUSS_RD_DIR}/src/oh_adapter/src
)
link_directories(
${THIRD_PARTY_DIR}/third_party_googletest/build/lib
${THIRD_PARTY_DIR}/third_party_jsoncpp/build/lib
${THIRD_PARTY_DIR}/third_party_openssl
${THIRD_PARTY_DIR}/third_party_zlib/build
${THIRD_PARTY_DIR}/third_party_sqlite
${THIRD_PARTY_DIR}/utils_native
${THIRD_PARTY_DIR}/third_party_cJSON/build
${THIRD_PARTY_DIR}/resourceschedule_ffrt/src
)
message("DB_PATH = ${DB_PATH}")
file(GLOB_RECURSE DISTRIBUTEDDB_SRC "${DB_PATH}/*.cpp")
list(REMOVE_ITEM DISTRIBUTEDDB_SRC "${DB_PATH}/test/unittest/common/storage/distributeddb_storage_encrypt_test.cpp")
file(GLOB_RECURSE RD_SRC "${DB_PATH}/gaussdb_rd/*.cpp")
list(REMOVE_ITEM DISTRIBUTEDDB_SRC ${RD_SRC}) # Contain illegal files led to chaos, exclude at first
file(GLOB_RECURSE GAUSSDB_RD_SRC "${DB_PATH}/gaussdb_rd/src/*.cpp")
list(APPEND DISTRIBUTEDDB_SRC ${GAUSSDB_RD_SRC})
foreach (ITR ${DISTRIBUTEDDB_SRC})
if ("${ITR}" MATCHES "(.*)moduletest(.*)")
# message(STATUS"Remove Item from List:${ITR}")
list (REMOVE_ITEM DISTRIBUTEDDB_SRC ${ITR})
endif ("${ITR}" MATCHES "(.*)moduletest(.*)")
endforeach(ITR)
file(GLOB_RECURSE FUZZTEST_SRC "${DB_PATH}/test/fuzztest/*.cpp")
if(FUZZTEST_SRC)
list(REMOVE_ITEM DISTRIBUTEDDB_SRC ${FUZZTEST_SRC})
endif()
set(DB_PATH ${PROJECT_SOURCE_DIR}/frameworks/libs/distributeddb)
add_executable(distributed_ut ${DISTRIBUTEDDB_SRC} ${SECUREC_SRC} ${SQLITE_SRC})
target_link_libraries(
distributed_ut
pthread
${CMAKE_THREAD_LIBS_INIT}
${PROJECT_SOURCE_DIR}/frameworks/libs/distributeddb/gaussdb_rd/build/libdocument_rd.a
securec
jsoncpp
ssl
crypto
sqlite3
z
gtest
gtest_main
cjson
gmock
gmock_main
dl
gcov
ffrt
)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/hongyangliu/distributeddatamgr_kv_store.git
git@gitee.com:hongyangliu/distributeddatamgr_kv_store.git
hongyangliu
distributeddatamgr_kv_store
distributeddatamgr_kv_store
db_master

搜索帮助