From 5dee76cda7cd7cb02877fe4cc86f824c512f01ae Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Sun, 16 Jan 2022 12:20:20 +0300 Subject: [PATCH] Remove unbundled zstd support --- CMakeLists.txt | 1 - cmake/find/rocksdb.cmake | 5 +---- cmake/find/zstd.cmake | 27 ------------------------- contrib/CMakeLists.txt | 5 +---- contrib/arrow-cmake/CMakeLists.txt | 9 +-------- contrib/librdkafka-cmake/CMakeLists.txt | 7 +++---- contrib/rocksdb-cmake/CMakeLists.txt | 2 +- contrib/zstd-cmake/CMakeLists.txt | 8 ++++---- src/CMakeLists.txt | 10 ++------- 9 files changed, 13 insertions(+), 61 deletions(-) delete mode 100644 cmake/find/zstd.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 4c9a972a4e4..c3d819d5813 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -495,7 +495,6 @@ include (cmake/find/ldap.cmake) # after ssl include (cmake/find/icu.cmake) include (cmake/find/xz.cmake) include (cmake/find/zlib.cmake) -include (cmake/find/zstd.cmake) include (cmake/find/ltdl.cmake) # for odbc # openssl, zlib before poco include (cmake/find/sparsehash.cmake) diff --git a/cmake/find/rocksdb.cmake b/cmake/find/rocksdb.cmake index 10592d1d037..c7d7c526297 100644 --- a/cmake/find/rocksdb.cmake +++ b/cmake/find/rocksdb.cmake @@ -36,16 +36,14 @@ if (NOT USE_INTERNAL_ROCKSDB_LIBRARY) endif() find_package(BZip2) - find_library(ZSTD_LIBRARY zstd) find_library(LZ4_LIBRARY lz4) find_library(GFLAGS_LIBRARY gflags) - if(SNAPPY_LIBRARY AND ZLIB_LIBRARY AND LZ4_LIBRARY AND BZIP2_FOUND AND ZSTD_LIBRARY AND GFLAGS_LIBRARY) + if(SNAPPY_LIBRARY AND ZLIB_LIBRARY AND LZ4_LIBRARY AND BZIP2_FOUND AND GFLAGS_LIBRARY) list (APPEND ROCKSDB_LIBRARY ${SNAPPY_LIBRARY}) list (APPEND ROCKSDB_LIBRARY ${ZLIB_LIBRARY}) list (APPEND ROCKSDB_LIBRARY ${LZ4_LIBRARY}) list (APPEND ROCKSDB_LIBRARY ${BZIP2_LIBRARY}) - list (APPEND ROCKSDB_LIBRARY ${ZSTD_LIBRARY}) list (APPEND ROCKSDB_LIBRARY ${GFLAGS_LIBRARY}) else() message (${RECONFIGURE_MESSAGE_LEVEL} @@ -53,7 +51,6 @@ if (NOT USE_INTERNAL_ROCKSDB_LIBRARY) " zlib=${ZLIB_LIBRARY} ;" " lz4=${LZ4_LIBRARY} ;" " bz2=${BZIP2_LIBRARY} ;" - " zstd=${ZSTD_LIBRARY} ;" " gflags=${GFLAGS_LIBRARY} ;") endif() endif () diff --git a/cmake/find/zstd.cmake b/cmake/find/zstd.cmake deleted file mode 100644 index 2b8dd53fbc3..00000000000 --- a/cmake/find/zstd.cmake +++ /dev/null @@ -1,27 +0,0 @@ -option (USE_INTERNAL_ZSTD_LIBRARY "Set to FALSE to use system zstd library instead of bundled" ON) - -if(NOT EXISTS "${ClickHouse_SOURCE_DIR}/contrib/zstd/lib/zstd.h") - if(USE_INTERNAL_ZSTD_LIBRARY) - message(WARNING "submodule contrib/zstd is missing. to fix try run: \n git submodule update --init") - message (${RECONFIGURE_MESSAGE_LEVEL} "Can't find internal zstd library") - set(USE_INTERNAL_ZSTD_LIBRARY 0) - endif() - set(MISSING_INTERNAL_ZSTD_LIBRARY 1) -endif() - -if (NOT USE_INTERNAL_ZSTD_LIBRARY) - find_library (ZSTD_LIBRARY zstd) - find_path (ZSTD_INCLUDE_DIR NAMES zstd.h PATHS ${ZSTD_INCLUDE_PATHS}) - if (NOT ZSTD_LIBRARY OR NOT ZSTD_INCLUDE_DIR) - message (${RECONFIGURE_MESSAGE_LEVEL} "Can't find system zstd library") - endif () -endif () - -if (ZSTD_LIBRARY AND ZSTD_INCLUDE_DIR) -elseif (NOT MISSING_INTERNAL_ZSTD_LIBRARY) - set (USE_INTERNAL_ZSTD_LIBRARY 1) - set (ZSTD_LIBRARY zstd) - set (ZSTD_INCLUDE_DIR ${ClickHouse_SOURCE_DIR}/contrib/zstd/lib) -endif () - -message (STATUS "Using zstd: ${ZSTD_INCLUDE_DIR} : ${ZSTD_LIBRARY}") diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt index 17954159b3a..bf2325453b8 100644 --- a/contrib/CMakeLists.txt +++ b/contrib/CMakeLists.txt @@ -56,13 +56,10 @@ endif() add_subdirectory (poco-cmake) add_subdirectory (croaring-cmake) +add_subdirectory (zstd-cmake) # TODO: refactor the contrib libraries below this comment. -if (USE_INTERNAL_ZSTD_LIBRARY) - add_subdirectory (zstd-cmake) -endif () - if (USE_INTERNAL_RE2_LIBRARY) add_subdirectory (re2-cmake) endif () diff --git a/contrib/arrow-cmake/CMakeLists.txt b/contrib/arrow-cmake/CMakeLists.txt index a28a83a87c5..6a481f412c8 100644 --- a/contrib/arrow-cmake/CMakeLists.txt +++ b/contrib/arrow-cmake/CMakeLists.txt @@ -311,10 +311,6 @@ if (ZLIB_INCLUDE_DIR AND ZLIB_LIBRARIES) set(ARROW_WITH_ZLIB 1) endif () -if (ZSTD_INCLUDE_DIR AND ZSTD_LIBRARY) - set(ARROW_WITH_ZSTD 1) -endif () - add_definitions(-DARROW_WITH_LZ4) SET(ARROW_SRCS "${LIBRARY_DIR}/util/compression_lz4.cc" ${ARROW_SRCS}) @@ -355,10 +351,7 @@ endif () if (ARROW_WITH_ZLIB) target_link_libraries(${ARROW_LIBRARY} PRIVATE ${ZLIB_LIBRARIES}) endif () -if (ARROW_WITH_ZSTD) - target_link_libraries(${ARROW_LIBRARY} PRIVATE ${ZSTD_LIBRARY}) - target_include_directories(${ARROW_LIBRARY} SYSTEM BEFORE PRIVATE ${ZLIB_INCLUDE_DIR}) -endif () +target_link_libraries(${ARROW_LIBRARY} PRIVATE ch_contrib::zstd) target_include_directories(${ARROW_LIBRARY} SYSTEM PRIVATE ${ORC_INCLUDE_DIR}) target_include_directories(${ARROW_LIBRARY} SYSTEM PRIVATE ${ORC_SOURCE_SRC_DIR}) diff --git a/contrib/librdkafka-cmake/CMakeLists.txt b/contrib/librdkafka-cmake/CMakeLists.txt index 97b6a7e1ec5..1a2821991a2 100644 --- a/contrib/librdkafka-cmake/CMakeLists.txt +++ b/contrib/librdkafka-cmake/CMakeLists.txt @@ -114,11 +114,10 @@ endif() add_library(rdkafka ${SRCS}) target_compile_options(rdkafka PRIVATE -fno-sanitize=undefined) # target_include_directories(rdkafka SYSTEM PUBLIC include) -target_include_directories(rdkafka SYSTEM PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include") # for "librdkafka/rdkafka.h" -target_include_directories(rdkafka SYSTEM PUBLIC ${RDKAFKA_SOURCE_DIR}) # Because weird logic with "include_next" is used. +target_include_directories(rdkafka SYSTEM PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include") # for "librdkafka/rdkafka.h" +target_include_directories(rdkafka SYSTEM PUBLIC ${RDKAFKA_SOURCE_DIR}) # Because weird logic with "include_next" is used. target_include_directories(rdkafka SYSTEM PUBLIC "${CMAKE_CURRENT_BINARY_DIR}/auxdir") # for "../config.h" -target_include_directories(rdkafka SYSTEM PRIVATE "${ZSTD_INCLUDE_DIR}/common") # Because wrong path to "zstd_errors.h" is used. -target_link_libraries(rdkafka PRIVATE lz4 ${ZLIB_LIBRARIES} ${ZSTD_LIBRARY}) +target_link_libraries(rdkafka PRIVATE lz4 ${ZLIB_LIBRARIES} ch_contrib::zstd) if(OPENSSL_SSL_LIBRARY AND OPENSSL_CRYPTO_LIBRARY) target_link_libraries(rdkafka PRIVATE ${OPENSSL_SSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY}) endif() diff --git a/contrib/rocksdb-cmake/CMakeLists.txt b/contrib/rocksdb-cmake/CMakeLists.txt index db0b3942b79..749147136f4 100644 --- a/contrib/rocksdb-cmake/CMakeLists.txt +++ b/contrib/rocksdb-cmake/CMakeLists.txt @@ -66,7 +66,7 @@ else() include_directories("${ZSTD_INCLUDE_DIR}/dictBuilder") include_directories("${ZSTD_INCLUDE_DIR}/deprecated") - list(APPEND THIRDPARTY_LIBS zstd) + list(APPEND THIRDPARTY_LIBS ch_contrib::zstd) endif() endif() diff --git a/contrib/zstd-cmake/CMakeLists.txt b/contrib/zstd-cmake/CMakeLists.txt index 226ee1a8067..4949c3f30d5 100644 --- a/contrib/zstd-cmake/CMakeLists.txt +++ b/contrib/zstd-cmake/CMakeLists.txt @@ -148,7 +148,7 @@ IF (ZSTD_LEGACY_SUPPORT) "${LIBRARY_LEGACY_DIR}/zstd_v07.h") ENDIF (ZSTD_LEGACY_SUPPORT) -ADD_LIBRARY(zstd ${Sources} ${Headers}) - -target_include_directories (zstd PUBLIC ${LIBRARY_DIR}) -target_compile_options(zstd PRIVATE -fno-sanitize=undefined) +add_library(_zstd ${Sources} ${Headers}) +add_library(ch_contrib::zstd ALIAS _zstd) +target_include_directories(_zstd BEFORE PUBLIC ${LIBRARY_DIR}) +target_compile_options(_zstd PRIVATE -fno-sanitize=undefined) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8d14bd327b1..e05bb14dbda 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -393,14 +393,8 @@ dbms_target_include_directories(SYSTEM BEFORE PUBLIC ${PDQSORT_INCLUDE_DIR}) target_include_directories(clickhouse_common_io SYSTEM BEFORE PUBLIC ${MINISELECT_INCLUDE_DIR}) dbms_target_include_directories(SYSTEM BEFORE PUBLIC ${MINISELECT_INCLUDE_DIR}) -if (ZSTD_LIBRARY) - dbms_target_link_libraries(PRIVATE ${ZSTD_LIBRARY}) - target_link_libraries (clickhouse_common_io PUBLIC ${ZSTD_LIBRARY}) - target_include_directories (clickhouse_common_io SYSTEM BEFORE PUBLIC ${ZSTD_INCLUDE_DIR}) - if (NOT USE_INTERNAL_ZSTD_LIBRARY AND ZSTD_INCLUDE_DIR) - dbms_target_include_directories(SYSTEM BEFORE PRIVATE ${ZSTD_INCLUDE_DIR}) - endif () -endif() +dbms_target_link_libraries(PRIVATE ch_contrib::zstd) +target_link_libraries (clickhouse_common_io PUBLIC ch_contrib::zstd) if (XZ_LIBRARY) target_link_libraries (clickhouse_common_io PUBLIC ${XZ_LIBRARY})