LZ4 - fix cmake to include lz4

This commit is contained in:
bharatnc 2021-06-17 01:31:37 -07:00
parent afad00b7d4
commit 7620c28c14
6 changed files with 44 additions and 1 deletions

View File

@ -540,6 +540,7 @@ include (cmake/find/rocksdb.cmake)
include (cmake/find/libpqxx.cmake)
include (cmake/find/nuraft.cmake)
include (cmake/find/yaml-cpp.cmake)
include (cmake/find/lz4.cmake)
if(NOT USE_INTERNAL_PARQUET_LIBRARY)
set (ENABLE_ORC OFF CACHE INTERNAL "")

27
cmake/find/lz4.cmake Normal file
View File

@ -0,0 +1,27 @@
option (USE_LZ4 "Set to FALSE to use system lz4 library instead of bundled" ${NOT_UNBUNDLED})
if(NOT EXISTS "${ClickHouse_SOURCE_DIR}/contrib/lz4/lib/lz4.h")
if(USE_LZ4)
message(WARNING "submodule contrib/lz4 is missing. to fix try run: \n git submodule update --init --recursive")
message (${RECONFIGURE_MESSAGE_LEVEL} "Can't find internal lz4 library")
set(USE_LZ4 0)
endif()
set(MISSING_INTERNAL_LZ4_LIBRARY 1)
endif()
if (NOT USE_LZ4)
find_library (LZ4_LIBRARY lz4)
find_path (LZ4_INCLUDE_DIR NAMES lz4.h PATHS ${LZ4_INCLUDE_PATHS})
if (NOT LZ4_LIBRARY OR NOT LZ4_INCLUDE_DIR)
message (${RECONFIGURE_MESSAGE_LEVEL} "Can't find system lz4 library")
endif ()
endif ()
if (LZ4_LIBRARY AND LZ4_INCLUDE_DIR)
elseif (NOT MISSING_INTERNAL_LZ4_LIBRARY)
set (USE_LZ4 1)
set (LZ4_LIBRARY lz4)
set (LZ4_INCLUDE_DIR ${ClickHouse_SOURCE_DIR}/contrib/lz4/lib)
endif ()
message (STATUS "Using lz4: ${LZ4_INCLUDE_DIR} : ${LZ4_LIBRARY}")

View File

@ -27,7 +27,14 @@ if (NOT EXTERNAL_LZ4_LIBRARY_FOUND)
"${LIBRARY_DIR}/lib/xxhash.c"
)
add_library (lz4 ${SRCS})
set (HEADERS
"${LIBRARY_DIR}/lib/lz4.h"
"${LIBRARY_DIR}/lib/lz4hc.h"
"${LIBRARY_DIR}/lib/lz4frame.h"
"${LIBRARY_DIR}/lib/xxhash.h"
)
add_library (lz4 ${SRCS} ${HEADERS})
target_compile_definitions (lz4 PUBLIC LZ4_DISABLE_DEPRECATE_WARNINGS=1 USE_XXHASH=1)
if (SANITIZE STREQUAL "undefined")

View File

@ -458,6 +458,11 @@ if (USE_DATASKETCHES)
target_include_directories (clickhouse_aggregate_functions SYSTEM BEFORE PRIVATE ${DATASKETCHES_INCLUDE_DIR})
endif ()
if (USE_LZ4)
target_link_libraries (clickhouse_common_io PRIVATE ${LZ4_LIBRARY})
target_include_directories (clickhouse_common_io SYSTEM BEFORE PRIVATE ${LZ4_INCLUDE_DIR})
endif()
dbms_target_link_libraries(PRIVATE _boost_context)
include ("${ClickHouse_SOURCE_DIR}/cmake/add_check.cmake")

View File

@ -4,6 +4,7 @@
#include <IO/CompressionMethod.h>
#include <IO/WriteBuffer.h>
#include <lz4.h>
namespace DB
{

View File

@ -4,6 +4,8 @@
#include <IO/CompressionMethod.h>
#include <IO/ReadBuffer.h>
#include <lz4.h>
namespace DB
{