# We set:
# - PNG_LIBRARIES
# - PNG_FOUND
# We do not set:
# - PNG_INCLUDE_DIRS
# Taking into account:
# - PNG_PREFIX

IF(NOT PNG_NAMES)
  SET(PNG_NAMES png png12 png14)
ENDIF(NOT PNG_NAMES)

foreach(l ${PNG_NAMES})
  list(APPEND PNG_DEBUG_NAMES "${l}d")
endforeach()

IF(WIN32)
  FIND_LIBRARY(PNG_LIB_RELEASE
    NAMES
      ${PNG_NAMES}
    PATHS
      ${PNG_PREFIX}/lib
  )
  FIND_LIBRARY(PNG_LIB_DEBUG
    NAMES
      ${PNG_DEBUG_NAMES}
    PATHS
      ${PNG_PREFIX}/lib
  )
  SET(PNG_LIBRARIES ${PNG_LIB_RELEASE})
  IF(PNG_LIB_RELEASE AND PNG_LIB_DEBUG)
    SET(PNG_LIBRARIES optimized ${PNG_LIB_RELEASE} debug ${PNG_LIB_DEBUG})
  ENDIF(PNG_LIB_RELEASE AND PNG_LIB_DEBUG)

ELSE(WIN32)
  FIND_LIBRARY(PNG_LIBRARIES
    NAMES
      png png12 png14
    PATHS
      ${PNG_PREFIX}/lib
      ${USERLIB_PREFIX}/lib
  )
ENDIF(WIN32)

IF(PNG_LIBRARIES)
  SET(PNG_FOUND TRUE)
  MESSAGE(STATUS "Found png libraries")
ELSE(PNG_LIBRARIES)
  SET(PNG_FOUND FALSE)
  MESSAGE(STATUS "Png libraries not found - set PNG_PREFIX")
ENDIF(PNG_LIBRARIES)



