# We set:
# - HARU_INCLUDE_DIRS
# - HARU_LIBRARIES
# - HARU_FOUND
# Taking into account:
# - HARU_PREFIX

FIND_PATH(HARU_INCLUDE_DIR
    hpdf.h
  PATHS
    ${HARU_PREFIX}/include
    ${HARU_PREFIX}/include/hpdf
    ${HARU_PREFIX}/include/libharu
    /usr/include
)

IF(WIN32)
  IF(HARU_DYNAMIC)
    SET(HARU_RELEASE_NAMES "libhpdf")
    SET(HARU_DEBUG_NAMES "libhpdfd")
  ELSE(HARU_DYNAMIC)
    SET(HARU_RELEASE_NAMES "libhpdfs")
    SET(HARU_DEBUG_NAMES "libhpdfsd")
  ENDIF(HARU_DYNAMIC)
  FIND_LIBRARY(HARU_LIB_RELEASE
    NAMES
      ${HARU_RELEASE_NAMES}
    PATHS
      ${HARU_PREFIX}/lib
  )
  FIND_LIBRARY(HARU_LIB_DEBUG
    NAMES
      ${HARU_DEBUG_NAMES}
    PATHS
      ${HARU_PREFIX}/lib
  )
  SET(HARU_LIB ${HARU_LIB_RELEASE})
  IF(HARU_LIB_RELEASE AND HARU_LIB_DEBUG)
    SET(HARU_LIB optimized ${HARU_LIB_RELEASE} debug ${HARU_LIB_DEBUG})
  ENDIF(HARU_LIB_RELEASE AND HARU_LIB_DEBUG)

  SET(HARU_SUPPORT_LIBS_FOUND FALSE)
  IF (PNG_LIBRARIES AND ZLIB_LIBRARIES)
    SET(HARU_SUPPORT_LIBS_FOUND TRUE)
    SET(HARU_SUPPORT_LIBS ${PNG_LIBRARIES} ${ZLIB_LIBRARIES})
  ENDIF (PNG_LIBRARIES AND ZLIB_LIBRARIES)
ELSE(WIN32)
  FIND_LIBRARY(HARU_LIB
    NAMES
      hpdf
      haru
    PATHS
      ${HARU_PREFIX}/lib
  )

  FIND_LIBRARY(M_LIB
    NAMES
      m
    PATHS
      ${HARU_PREFIX}/lib
      ${USERLIB_PREFIX}/lib
      /lib/x86_64-linux-gnu
  )

  SET(HARU_SUPPORT_LIBS_FOUND FALSE)

  IF (PNG_LIBRARIES AND M_LIB AND ZLIB_LIBRARIES)
    SET(HARU_SUPPORT_LIBS_FOUND TRUE)
    SET(HARU_SUPPORT_LIBS ${PNG_LIBRARIES} ${M_LIB} ${ZLIB_LIBRARIES})
  ENDIF (PNG_LIBRARIES AND M_LIB AND ZLIB_LIBRARIES)
ENDIF(WIN32)

IF(HARU_LIB AND HARU_INCLUDE_DIR AND HARU_SUPPORT_LIBS_FOUND)
  SET(HARU_FOUND TRUE)
  SET(HARU_INCLUDE_DIRS ${HARU_INCLUDE_DIR})
  SET(HARU_LIBRARIES ${HARU_LIB} ${HARU_SUPPORT_LIBS})
  MESSAGE(STATUS "Found libharu libraries")
ELSE(HARU_LIB AND HARU_INCLUDE_DIR AND HARU_SUPPORT_LIBS_FOUND)
  SET(HARU_FOUND FALSE)
  MESSAGE(STATUS "libharu libraries not found - set HARU_PREFIX")
ENDIF(HARU_LIB AND HARU_INCLUDE_DIR AND HARU_SUPPORT_LIBS_FOUND)



