# - Find Snappy
# Find the snappy compression library and includes
#
# SNAPPY_INCLUDE_DIRS - where to find snappy.h, etc.
# SNAPPY_LIBRARIES - List of libraries when using snappy.
# SNAPPY_FOUND - True if snappy found.

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

FIND_PATH(SNAPPY_INCLUDE_DIRS NAMES snappy.h HINTS ${snappy_ROOT_DIR}/include)

IF(SNAPPY_USE_STATIC)
  FIND_LIBRARY(SNAPPY_LIBRARIES NAMES libsnappy.a HINTS ${snappy_ROOT_DIR}/lib)
ELSE()
  FIND_LIBRARY(SNAPPY_LIBRARIES NAMES snappy HINTS ${snappy_ROOT_DIR}/lib)
ENDIF(SNAPPY_USE_STATIC)

INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Snappy DEFAULT_MSG SNAPPY_LIBRARIES SNAPPY_INCLUDE_DIRS)

MARK_AS_ADVANCED(SNAPPY_LIBRARIES SNAPPY_INCLUDE_DIRS)

IF(SNAPPY_FOUND AND NOT (TARGET Snappy::snappy))
  ADD_LIBRARY(Snappy::snappy UNKNOWN IMPORTED)
  SET_TARGET_PROPERTIES(Snappy::snappy PROPERTIES IMPORTED_LOCATION ${SNAPPY_LIBRARIES} INTERFACE_INCLUDE_DIRECTORIES ${SNAPPY_INCLUDE_DIRS})
ENDIF()
