diff --git a/cmake/find_xxhash.cmake b/cmake/find_xxhash.cmake index 41e323ffe67..8af871e8fd5 100644 --- a/cmake/find_xxhash.cmake +++ b/cmake/find_xxhash.cmake @@ -1,15 +1,22 @@ -# Freebsd: TODO: use system devel/xxhash. now error: undefined reference to `XXH32' -if (LZ4_INCLUDE_DIR) - if (NOT EXISTS "${LZ4_INCLUDE_DIR}/xxhash.h") - message (WARNING "LZ4 library does not have XXHash. Support for XXHash will be disabled.") - set (USE_XXHASH 0) - else () - set (USE_XXHASH 1) - endif () +option (USE_INTERNAL_XXHASH_LIBRARY "Set to FALSE to use system xxHash library instead of bundled" ${NOT_UNBUNDLED}) + +if (USE_INTERNAL_XXHASH_LIBRARY AND NOT USE_INTERNAL_LZ4_LIBRARY) + message (WARNING "can not use internal xxhash without internal lz4") + set (USE_INTERNAL_XXHASH_LIBRARY 0) endif () -if (OS_FREEBSD AND NOT USE_INTERNAL_LZ4_LIBRARY) +if (USE_INTERNAL_XXHASH_LIBRARY) + set (XXHASH_LIBRARY lz4) + set (XXHASH_INCLUDE_DIR ${ClickHouse_SOURCE_DIR}/contrib/lz4/lib) +else () + find_library (XXHASH_LIBRARY xxhash) + find_path (XXHASH_INCLUDE_DIR NAMES xxhash.h PATHS ${XXHASH_INCLUDE_PATHS}) +endif () + +if (XXHASH_LIBRARY AND XXHASH_INCLUDE_DIR) + set (USE_XXHASH 1) +else () set (USE_XXHASH 0) endif () -message (STATUS "Using xxhash=${USE_XXHASH}") +message (STATUS "Using xxhash=${USE_XXHASH}: ${XXHASH_INCLUDE_DIR} : ${XXHASH_LIBRARY}") diff --git a/dbms/src/Functions/CMakeLists.txt b/dbms/src/Functions/CMakeLists.txt index 89807a428e3..e767c17de92 100644 --- a/dbms/src/Functions/CMakeLists.txt +++ b/dbms/src/Functions/CMakeLists.txt @@ -20,8 +20,7 @@ target_link_libraries(clickhouse_functions ${METROHASH_LIBRARIES} murmurhash ${BASE64_LIBRARY} - ${OPENSSL_CRYPTO_LIBRARY} - ${LZ4_LIBRARY}) + ${OPENSSL_CRYPTO_LIBRARY}) target_include_directories (clickhouse_functions SYSTEM BEFORE PUBLIC ${DIVIDE_INCLUDE_DIR} ${METROHASH_INCLUDE_DIR}) @@ -56,3 +55,8 @@ endif () if(USE_BASE64) target_include_directories(clickhouse_functions SYSTEM PRIVATE ${BASE64_INCLUDE_DIR}) endif() + +if (USE_XXHASH) + target_link_libraries(clickhouse_functions PRIVATE ${XXHASH_LIBRARY}) + target_include_directories(clickhouse_functions SYSTEM PRIVATE ${XXHASH_INCLUDE_DIR}) +endif()