# This file defines:
# - ZLIB_INCLUDE_DIRS
# - ZLIB_LIBRARIES
# - ZLIB_FOUND
# - ZLIB_DEFINITIONS
# Taking into account:
# - ZLIB_PREFIX

FIND_PATH(ZLIB_INCLUDE zlib.h
  ${ZLIB_PREFIX}/include
  /usr/include
)

IF(WIN32)
  FIND_LIBRARY(ZLIB_LIB_RELEASE
    NAMES
      zlibstat zlib 
    PATHS
      /usr/lib
      ${ZLIB_PREFIX}/lib
  )

  FIND_LIBRARY(ZLIB_LIB_DEBUG
    NAMES
      zlibstatd
    PATHS
      ${ZLIB_PREFIX}/lib
  )

  IF(ZLIB_INCLUDE AND ZLIB_LIB_RELEASE AND ZLIB_LIB_DEBUG)
    SET(ZLIB_FOUND TRUE)
    SET(ZLIB_DEFINITIONS -DZLIB_WINAPI)
    SET(ZLIB_INCLUDE_DIRS ${ZLIB_INCLUDE})
    SET(ZLIB_LIBRARIES optimized ${ZLIB_LIB_RELEASE} debug ${ZLIB_LIB_DEBUG})
  ELSE(ZLIB_INCLUDE AND ZLIB_LIB_RELEASE AND ZLIB_LIB_DEBUG)
    SET(ZLIB_FOUND FALSE)
  ENDIF(ZLIB_INCLUDE AND ZLIB_LIB_RELEASE AND ZLIB_LIB_DEBUG)
ELSE(WIN32)
  FIND_LIBRARY(ZLIB_LIB
    NAMES
      z
    PATHS
      /usr/lib
      ${ZLIB_PREFIX}/lib
  )

  IF(ZLIB_INCLUDE AND ZLIB_LIB)
    SET(ZLIB_FOUND TRUE)
    SET(ZLIB_INCLUDE_DIRS ${ZLIB_INCLUDE})
    SET(ZLIB_LIBRARIES ${ZLIB_LIB})
  ELSE(ZLIB_INCLUDE AND ZLIB_LIB)
    SET(ZLIB_FOUND FALSE)
  ENDIF(ZLIB_INCLUDE AND ZLIB_LIB)
ENDIF(WIN32)

