From bf6e59134d621ca0ad495a4f9f6b0f659b19e625 Mon Sep 17 00:00:00 2001 From: Contrary Date: Thu, 20 Mar 2025 21:44:57 +0800 Subject: [PATCH] Optimize main CMakeLists This commit includes the following three changes: 1. Use spaces to distinguish different third-party libraries until the end of restore_compile_flags() function. 2. Move folly related comments to the unified location of folly library. 3. Move rocksdb compilation item addition statement to the unified location of rocksdb library. Signed-off-by: Contrary --- CMakeLists.txt | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b997361..a39b0f2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -78,14 +78,16 @@ elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64") message(STATUS "ARM architecture detected, linking with compiler-rt and libgcc.") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -rtlib=compiler-rt -unwindlib=libgcc") endif() -add_compile_definitions(ROCKSDB_NAMESPACE=rocksdb_internal) + include(cmake/Sanitizers.cmake) include(cmake/CompileFlags.cmake) - -# folly can't work normally under -Werror store_compile_flags() + +# fmt add_subdirectory("third_party/fmt" EXCLUDE_FROM_ALL) restore_compile_flags() + +# zstd set(ZSTD_BUILD_STATIC ON) add_subdirectory("third_party/zstd/build/cmake" EXCLUDE_FROM_ALL) set(zstd_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/third_party/zstd/lib") @@ -95,16 +97,26 @@ set(ZSTD_FOUND ON) set(zstd_LIBRARIES "${PROJECT_BINARY_DIR}/third_party/zstd/build/cmake/lib/libzstd.a") set(ZSTD_LIBRARY "${PROJECT_BINARY_DIR}/third_party/zstd/build/cmake/lib/libzstd.a") restore_compile_flags() + +# googletest add_subdirectory("third_party/googletest" EXCLUDE_FROM_ALL) restore_compile_flags() + +# folly +# folly can't work normally under -Werror set(FOLLY_NO_EXCEPTION_TRACER ON) add_subdirectory("third_party/folly" EXCLUDE_FROM_ALL) restore_compile_flags() + +# leveldb set(LEVELDB_BUILD_TESTS OFF CACHE BOOL "Disable LevelDB tests") set(LEVELDB_BUILD_BENCHMARKS OFF CACHE BOOL "Disable LevelDB benchmarks") set(LEVELDB_INSTALL OFF CACHE BOOL "Disable LevelDB install") add_subdirectory("third_party/leveldb" EXCLUDE_FROM_ALL) restore_compile_flags() + +# rocksdb +add_compile_definitions(ROCKSDB_NAMESPACE=rocksdb_internal) set(CMAKE_POLICY_DEFAULT_CMP0077 NEW) set(WITH_LZ4 ON) set(WITH_ZSTD ON) @@ -113,9 +125,10 @@ set(WITH_TESTS OFF) set(WITH_BENCHMARK_TOOLS OFF) set(WITH_TOOLS OFF) set(WITH_ALL_TESTS OFF) - add_subdirectory("third_party/rocksdb" EXCLUDE_FROM_ALL) restore_compile_flags() + +# scnlib set(SCN_TESTS OFF) set(SCN_EXAMPLES OFF) set(SCN_BENCHMARKS OFF) @@ -124,13 +137,21 @@ set(SCN_INSTALL OFF) set(SCN_PEDANTIC OFF) add_subdirectory("third_party/scnlib" EXCLUDE_FROM_ALL) restore_compile_flags() + +# pybind11 add_subdirectory("third_party/pybind11" EXCLUDE_FROM_ALL) restore_compile_flags() + +# toml11 add_subdirectory("third_party/toml11" EXCLUDE_FROM_ALL) restore_compile_flags() + +# mimalloc set (MI_OVERRIDE OFF) add_subdirectory("third_party/mimalloc" EXCLUDE_FROM_ALL) restore_compile_flags() + +# clickhouse-cpp add_subdirectory("third_party/clickhouse-cpp" EXCLUDE_FROM_ALL) TARGET_INCLUDE_DIRECTORIES(clickhouse-cpp-lib PUBLIC ${PROJECT_SOURCE_DIR}/third_party/clickhouse-cpp @@ -142,6 +163,8 @@ TARGET_INCLUDE_DIRECTORIES (absl-lib PUBLIC ${PROJECT_SOURCE_DIR}/third_party/clickhouse-cpp/contrib ) restore_compile_flags() + +# liburing add_subdirectory("third_party/liburing-cmake" EXCLUDE_FROM_ALL) restore_compile_flags()