Remove unbundled snappy support

This commit is contained in:
Azat Khuzhin 2022-01-16 23:00:25 +03:00
parent ab8cdb198f
commit 1145e32af6
9 changed files with 27 additions and 56 deletions

View File

@ -1,21 +0,0 @@
option(USE_SNAPPY "Enable snappy library" ON)
if(NOT USE_SNAPPY)
if (USE_INTERNAL_SNAPPY_LIBRARY)
message (${RECONFIGURE_MESSAGE_LEVEL} "Can't use internal snappy library with USE_SNAPPY=OFF")
endif()
return()
endif()
option (USE_INTERNAL_SNAPPY_LIBRARY "Set to FALSE to use system snappy library instead of bundled" ON)
if(NOT USE_INTERNAL_SNAPPY_LIBRARY)
find_library(SNAPPY_LIBRARY snappy)
if (NOT SNAPPY_LIBRARY)
message (${RECONFIGURE_MESSAGE_LEVEL} "Can't find system snappy library")
endif()
else ()
set(SNAPPY_LIBRARY snappy)
endif()
message (STATUS "Using snappy: ${SNAPPY_LIBRARY}")

View File

@ -58,10 +58,11 @@ add_subdirectory (poco-cmake)
add_subdirectory (croaring-cmake)
add_subdirectory (zstd-cmake)
add_subdirectory (zlib-ng-cmake)
add_subdirectory (rocksdb-cmake)
add_subdirectory (bzip2-cmake)
add_subdirectory (snappy-cmake)
add_subdirectory (rocksdb-cmake)
# parquet/arrow/orc
add_subdirectory (arrow-cmake)
add_subdirectory (arrow-cmake) # requires: snappy
add_subdirectory (avro-cmake) # requires: snappy
# TODO: refactor the contrib libraries below this comment.
@ -116,14 +117,6 @@ if (ENABLE_ICU AND USE_INTERNAL_ICU_LIBRARY)
add_subdirectory (icu-cmake)
endif ()
if(USE_INTERNAL_SNAPPY_LIBRARY)
set(SNAPPY_BUILD_TESTS 0 CACHE INTERNAL "")
add_subdirectory(snappy-cmake)
set (SNAPPY_INCLUDE_DIR "${ClickHouse_SOURCE_DIR}/contrib/snappy")
endif()
if(USE_INTERNAL_GTEST_LIBRARY)
add_subdirectory(googletest-cmake)
elseif(GTEST_SRC_DIR)

View File

@ -344,17 +344,11 @@ set(ARROW_SRCS
${ORC_SRCS}
)
if (SNAPPY_INCLUDE_DIR AND SNAPPY_LIBRARY)
set(ARROW_WITH_SNAPPY 1)
endif ()
add_definitions(-DARROW_WITH_LZ4)
SET(ARROW_SRCS "${LIBRARY_DIR}/util/compression_lz4.cc" ${ARROW_SRCS})
if (ARROW_WITH_SNAPPY)
add_definitions(-DARROW_WITH_SNAPPY)
SET(ARROW_SRCS "${LIBRARY_DIR}/util/compression_snappy.cc" ${ARROW_SRCS})
endif ()
add_definitions(-DARROW_WITH_SNAPPY)
SET(ARROW_SRCS "${LIBRARY_DIR}/util/compression_snappy.cc" ${ARROW_SRCS})
add_definitions(-DARROW_WITH_ZLIB)
SET(ARROW_SRCS "${LIBRARY_DIR}/util/compression_zlib.cc" ${ARROW_SRCS})
@ -380,9 +374,7 @@ target_include_directories(_arrow SYSTEM BEFORE PUBLIC ${ARROW_SRC_DIR})
target_include_directories(_arrow SYSTEM BEFORE PUBLIC "${CMAKE_CURRENT_BINARY_DIR}/cpp/src")
target_link_libraries(_arrow PRIVATE ${DOUBLE_CONVERSION_LIBRARIES} ${Protobuf_LIBRARY})
target_link_libraries(_arrow PRIVATE lz4)
if (ARROW_WITH_SNAPPY)
target_link_libraries(_arrow PRIVATE ${SNAPPY_LIBRARY})
endif ()
target_link_libraries(_arrow PRIVATE ch_contrib::snappy)
target_link_libraries(_arrow PRIVATE ch_contrib::zlib)
target_link_libraries(_arrow PRIVATE ch_contrib::zstd)

View File

@ -56,12 +56,9 @@ target_include_directories(_avrocpp SYSTEM PUBLIC ${AVROCPP_INCLUDE_DIR})
target_link_libraries (_avrocpp PRIVATE boost::headers_only boost::iostreams)
# include(cmake/find/snappy.cmake)
if (SNAPPY_INCLUDE_DIR AND SNAPPY_LIBRARY)
target_compile_definitions (_avrocpp PUBLIC SNAPPY_CODEC_AVAILABLE)
target_include_directories (_avrocpp PRIVATE ${SNAPPY_INCLUDE_DIR})
target_link_libraries (_avrocpp PRIVATE ${SNAPPY_LIBRARY})
endif ()
target_compile_definitions (_avrocpp PUBLIC SNAPPY_CODEC_AVAILABLE)
target_include_directories (_avrocpp PRIVATE ${SNAPPY_INCLUDE_DIR})
target_link_libraries (_avrocpp PRIVATE ch_contrib::snappy)
if (COMPILER_GCC)
set (SUPPRESS_WARNINGS -Wno-non-virtual-dtor)

View File

@ -13,6 +13,10 @@ set(PORTABLE ON)
## always disable jemalloc for rocksdb by default
## because it introduces non-standard jemalloc APIs
option(WITH_JEMALLOC "build with JeMalloc" OFF)
set(USE_SNAPPY OFF)
if (TARGET ch_contrib::snappy)
set(USE_SNAPPY ON)
endif()
option(WITH_SNAPPY "build with SNAPPY" ${USE_SNAPPY})
## lz4, zlib, zstd is enabled in ClickHouse by default
option(WITH_LZ4 "build with lz4" ON)
@ -53,7 +57,7 @@ else()
if(WITH_SNAPPY)
add_definitions(-DSNAPPY)
list(APPEND THIRDPARTY_LIBS snappy)
list(APPEND THIRDPARTY_LIBS ch_contrib::snappy)
endif()
if(WITH_ZLIB)

View File

@ -30,8 +30,9 @@ configure_file(
"${SOURCE_DIR}/snappy-stubs-public.h.in"
"${CMAKE_CURRENT_BINARY_DIR}/snappy-stubs-public.h")
add_library(snappy "")
target_sources(snappy
add_library(_snappy "")
add_library(ch_contrib::snappy ALIAS _snappy)
target_sources(_snappy
PRIVATE
"${SOURCE_DIR}/snappy-internal.h"
"${SOURCE_DIR}/snappy-stubs-internal.h"
@ -40,5 +41,5 @@ target_sources(snappy
"${SOURCE_DIR}/snappy-stubs-internal.cc"
"${SOURCE_DIR}/snappy.cc")
target_include_directories(snappy SYSTEM PUBLIC ${SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
target_compile_definitions(snappy PRIVATE -DHAVE_CONFIG_H)
target_include_directories(_snappy SYSTEM BEFORE PUBLIC ${SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
target_compile_definitions(_snappy PRIVATE -DHAVE_CONFIG_H)

View File

@ -471,9 +471,8 @@ if (USE_BROTLI)
target_include_directories (clickhouse_common_io SYSTEM BEFORE PRIVATE ${BROTLI_INCLUDE_DIR})
endif()
if (USE_SNAPPY)
target_link_libraries (clickhouse_common_io PUBLIC ${SNAPPY_LIBRARY})
target_include_directories (clickhouse_common_io SYSTEM BEFORE PUBLIC ${SNAPPY_INCLUDE_DIR})
if (TARGET ch_contrib::snappy)
target_link_libraries (clickhouse_common_io PUBLIC ch_contrib::snappy)
endif()
if (USE_AMQPCPP)

View File

@ -6,4 +6,7 @@ if (TARGET ch_contrib::parquet)
set(USE_ARROW 1)
set(USE_ORC 1)
endif()
if (TARGET ch_contrib::snappy)
set(USE_SNAPPY 1)
endif()
configure_file(config_formats.h.in ${ConfigIncludePath}/config_formats.h)

View File

@ -4,3 +4,6 @@ endif()
if (TARGET ch_contrib::bzip2)
set(USE_BZIP2 1)
endif()
if (TARGET ch_contrib::snappy)
set(USE_SNAPPY 1)
endif()