# Find the thrift library.
#
# This module defines
#  THRIFT_FOUND             - True if THRIFT was found.
#  THRIFT_INCLUDE_DIRS      - Include directories for THRIFT headers.
#  THRIFT_LIBRARIES         - Libraries for THRIFT.
#
# To specify an additional directory to search, set THRIFT_ROOT.
#
# Copyright (c) 2010, Ewen Cheslack-Postava
# Based on FindSQLite3.cmake by:
#  Copyright (c) 2006, Jaroslaw Staniek, <js@iidea.pl>
#  Extended by Siddhartha Chaudhuri, 2008.
#
# Redistribution and use is allowed according to the terms of the BSD license.
#

SET(LZHAM_FOUND FALSE)
SET(LZHAM_INCLUDE_DIRS)
SET(LZHAM_LIBRARIES)

IF(LZHAM_ROOT)
  SET(SEARCH_PATHS
    ${LZHAM_ROOT}/
    ${SEARCH_PATHS}
    )
ENDIF()

FIND_PATH(LZHAM_INCLUDE_DIRS
  NAMES include/lzham.h
  PATHS ${SEARCH_PATHS}
  NO_DEFAULT_PATH)
IF(NOT LZHAM_INCLUDE_DIRS)  # now look in system locations
  FIND_PATH(LZHAM_INCLUDE_DIRS NAMES lzma.h)
ENDIF(NOT LZHAM_INCLUDE_DIRS)
SET(LZHAM_LIBRARY_DIRS)
IF(LZHAM_ROOT)
  SET(LZHAM_LIBRARY_DIRS ${LZHAM_ROOT})
  IF(EXISTS "${LZHAM_ROOT}/lib")
    SET(LZHAM_LIBRARY_DIRS ${LZHAM_LIBRARY_DIRS} ${LZHAM_ROOT}/lib)
  ENDIF()
ENDIF()
# Without system dirs
FIND_LIBRARY(LZHAM_DECOMP_LIBRARY
  NAMES lzhamdecomp
  PATHS ${LZHAM_LIBRARY_DIRS}
  NO_DEFAULT_PATH
  )
# Without system dirs
FIND_LIBRARY(LZHAM_COMP_LIBRARY
  NAMES lzhamcomp
  PATHS ${LZHAM_LIBRARY_DIRS}
  NO_DEFAULT_PATH
  )
# Without system dirs
FIND_LIBRARY(LZHAM_DY_LIBRARY
  NAMES lzhamdll
  PATHS ${LZHAM_LIBRARY_DIRS}
  NO_DEFAULT_PATH
  )
IF(NOT LZHAM_COMP_LIBRARY)  # now look in system locations
  FIND_LIBRARY(LZHAM_COMP_LIBRARY NAMES lzhamdecmop)
  FIND_LIBRARY(LZHAM_DECOMP_LIBRARY NAMES lzhamcomp)
  FIND_LIBRARY(LZHAM_DY_LIBRARY NAMES lzhamdll)
ENDIF(NOT LZHAM_COMP_LIBRARY)

SET(LZHAM_LIBRARIES)
IF(LZHAM_COMP_LIBRARY)
  SET(LZHAM_LIBRARIES ${LZHAM_COMP_LIBRARY} ${LZHAM_DECOMP_LIBRARY} ${LZHAM_DY_LIBRARY})
ENDIF()

IF(LZHAM_INCLUDE_DIRS AND LZHAM_LIBRARIES)
  SET(LZHAM_FOUND TRUE)
  IF(NOT LZHAM_FIND_QUIETLY)
    MESSAGE(STATUS "Found lzham: headers at ${LZHAM_INCLUDE_DIRS}, libraries at ${LZHAM_LIBRARY_DIRS} :: ${LZHAM_LIBRARIES}")
  ENDIF(NOT LZHAM_FIND_QUIETLY)
ELSE(LZHAM_INCLUDE_DIRS AND LZHAM_LIBRARIES)
  SET(LZHAM_FOUND FALSE)
  IF(LZHAM_FIND_REQUIRED)
    MESSAGE(STATUS "lzham not found")
  ENDIF(LZHAM_FIND_REQUIRED)
ENDIF(LZHAM_INCLUDE_DIRS AND LZHAM_LIBRARIES)

MARK_AS_ADVANCED(LZHAM_INCLUDE_DIRS LZHAM_LIBRARIES)
