ClickHouse/contrib/lz4-cmake/CMakeLists.txt
Konstantin Podshumok d456aa86ef
Revert "Revert "cmake: Add option to fail configuration instead of auto-reconfiguration""
This reverts commit 89419ceb9b
(curl part moved to separate commit)

Squashed:
- termcap removed
- fix for cassandra on apple merged
- cmake: fix "Can't find system zlib library" in unbundled build
- cmake: fix condition when testing for rdkafka platform
- cmake: PROTOBUF_OLD_ABI_COMPAT shouldn't be enabled for internal protobuf

Signed-off-by: Konstantin Podshumok <kpp.live+signed@gmail.com>
2020-08-25 20:16:37 +03:00

38 lines
1.3 KiB
CMake

option (USE_INTERNAL_LZ4_LIBRARY "Use internal lz4 library" ${NOT_UNBUNDLED})
if (NOT USE_INTERNAL_LZ4_LIBRARY)
find_library (LIBRARY_LZ4 lz4)
find_path (INCLUDE_LZ4 lz4.h)
if (LIBRARY_LZ4 AND INCLUDE_LZ4)
set(EXTERNAL_LZ4_LIBRARY_FOUND 1)
add_library (lz4 UNKNOWN IMPORTED)
set_property (TARGET lz4 PROPERTY IMPORTED_LOCATION ${LIBRARY_LZ4})
set_property (TARGET lz4 PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${INCLUDE_LZ4})
set_property (TARGET lz4 APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS USE_XXHASH=0)
else()
set(EXTERNAL_LZ4_LIBRARY_FOUND 0)
message (${RECONFIGURE_MESSAGE_LEVEL} "Can't find system lz4")
endif()
endif()
if (NOT EXTERNAL_LZ4_LIBRARY_FOUND)
set (USE_INTERNAL_LZ4_LIBRARY 1)
set (LIBRARY_DIR "${ClickHouse_SOURCE_DIR}/contrib/lz4")
set (SRCS
"${LIBRARY_DIR}/lib/lz4.c"
"${LIBRARY_DIR}/lib/lz4hc.c"
"${LIBRARY_DIR}/lib/lz4frame.c"
"${LIBRARY_DIR}/lib/xxhash.c"
)
add_library (lz4 ${SRCS})
target_compile_definitions (lz4 PUBLIC LZ4_DISABLE_DEPRECATE_WARNINGS=1 USE_XXHASH=1)
if (SANITIZE STREQUAL "undefined")
target_compile_options (lz4 PRIVATE -fno-sanitize=undefined)
endif ()
target_include_directories(lz4 PUBLIC ${LIBRARY_DIR}/lib)
endif ()