# - Find Lz4
# Find the lz4 compression library and includes
#
# LZ4_INCLUDE_DIRS - where to find lz4.h, etc.
# LZ4_LIBRARIES - List of libraries when using lz4.
# LZ4_FOUND - True if lz4 found.

IF(LZ4_USE_STATIC)
  MESSAGE(STATUS "LZ4_USE_STATIC: ON")
ELSE()
  MESSAGE(STATUS "LZ4_USE_STATIC: OFF")
ENDIF()

FIND_PATH(LZ4_INCLUDE_DIRS NAMES lz4.h HINTS ${LZ4_ROOT_DIR}/include)

IF(LZ4_USE_STATIC)
  FIND_LIBRARY(LZ4_LIBRARIES NAMES liblz4.a HINTS ${LZ4_ROOT_DIR}/lib)
ELSE()
  FIND_LIBRARY(LZ4_LIBRARIES NAMES lz4 HINTS ${LZ4_ROOT_DIR}/lib)
ENDIF()

INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(lz4 DEFAULT_MSG LZ4_LIBRARIES LZ4_INCLUDE_DIRS)

MARK_AS_ADVANCED(LZ4_LIBRARIES LZ4_INCLUDE_DIRS)

IF(LZ4_FOUND AND NOT (TARGET lz4::lz4))
  ADD_LIBRARY(lz4::lz4 UNKNOWN IMPORTED)
  SET_TARGET_PROPERTIES(lz4::lz4 PROPERTIES IMPORTED_LOCATION ${LZ4_LIBRARIES} INTERFACE_INCLUDE_DIRECTORIES ${LZ4_INCLUDE_DIRS})
ENDIF()
