Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 29 additions & 3 deletions cmake/modules/FindLZ4.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,23 @@ if(LZ4_CONFIG_EXECUTABLE)
endif()
set(LZ4_FOUND 0)

find_path(LZ4_INCLUDE_DIR lz4.h
find_path(LZ4_INCLUDE_DIR NAMES lz4.h PATHS
$ENV{LZ4_DIR}/include
/usr/include
/usr/local/include
/opt/lz4/include
DOC "Specify the directory containing lz4.h"
)

# Checking for xxhash library includes (part of https://github.com/lz4/lz4.git,
# but not provided in .deb and .rpm packages)
find_path(XXHASH_INCLUDE_DIR NAMES xxhash.h PATHS
/usr/include
/usr/local/include
/opt/xxhash/include
DOC "Specify the directory containing xxhash.h"
)

find_library(LZ4_LIBRARY NAMES lz4 PATHS
$ENV{LZ4_DIR}/lib
/usr/local/lz4/lib
Expand All @@ -29,13 +39,29 @@ find_library(LZ4_LIBRARY NAMES lz4 PATHS
DOC "Specify the lz4 library here."
)

if(LZ4_INCLUDE_DIR AND LZ4_LIBRARY)
# Checking for xxhash library, in case it was built separately from
# https://github.com/Cyan4973/xxHash.git
find_library(XXHASH_LIBRARY NAMES xxhash PATHS
/usr/local/lib
/usr/lib
DOC "Specify the xxhash library here."
)

if(LZ4_INCLUDE_DIR AND LZ4_LIBRARY AND XXHASH_INCLUDE_DIR)
set(LZ4_FOUND 1)
if(NOT LZ4_FIND_QUIETLY)
message(STATUS "Found LZ4 includes at ${LZ4_INCLUDE_DIR}")
message(STATUS "Found LZ4 library at ${LZ4_LIBRARY}")
message(STATUS "Found xxhash include at ${XXHASH_INCLUDE_DIR}")
endif()
endif()

set(LZ4_LIBRARIES ${LZ4_LIBRARY})
mark_as_advanced(LZ4_FOUND LZ4_LIBRARY LZ4_INCLUDE_DIR)
if(XXHASH_LIBRARY)
list(APPEND LZ4_LIBRARIES ${XXHASH_LIBRARY})
endif()
if(NOT("${XXHASH_INCLUDE_DIR}" MATCHES ${LZ4_INCLUDE_DIR}))
list(APPEND LZ4_INCLUDE_DIR ${XXHASH_INCLUDE_DIR})
endif()

mark_as_advanced(LZ4_FOUND LZ4_LIBRARY LZ4_INCLUDE_DIR XXHASH_INCLUDE_DIR)