FIND_PACKAGE(ZLIB)

IF(LIBZIP_DIR)
  FIND_PATH(LIBZIP_INCLUDE_DIR_zh NAMES zip.h NO_DEFAULT_PATH PATHS ${LIBZIP_DIR}/include ${LIBZIP_DIR})
  FIND_PATH(LIBZIP_INCLUDE_DIR_zch NAMES zipconf.h NO_DEFAULT_PATH PATHS ${LIBZIP_DIR}/lib/libzip/include ${LIBZIP_DIR}/include ${LIBZIP_DIR})
  FIND_LIBRARY(LIBZIP_LIBRARY NAMES zip NO_DEFAULT_PATH PATHS ${LIBZIP_DIR}/lib ${LIBZIP_DIR})
ELSE()
  FIND_PATH(LIBZIP_INCLUDE_DIR_zh NAMES zip.h PATHS /include /usr/include /usr/local/include /opt/local/include)
  FIND_PATH(LIBZIP_INCLUDE_DIR_zch NAMES zipconf.h PATHS /lib/libzip/include /usr/lib/libzip/include /usr/local/lib/libzip/include /opt/local/lib/libzip/include /include /usr/include /usr/local/include /opt/local/include)
  FIND_LIBRARY(LIBZIP_LIBRARY NAMES zip)
ENDIF()

IF (LIBZIP_INCLUDE_DIR_zh AND LIBZIP_INCLUDE_DIR_zch AND LIBZIP_LIBRARY)
  SET(LIBZIP_INCLUDE_DIRS "${LIBZIP_INCLUDE_DIR_zh};${LIBZIP_INCLUDE_DIR_zch};${ZLIB_INCLUDE_DIRS}")
  SET(LIBZIP_LIBRARIES ${LIBZIP_LIBRARY} ${ZLIB_LIBRARIES})
  SET(LIBZIP_FOUND true)
ENDIF()
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibZip DEFAULT_MSG LIBZIP_LIBRARIES LIBZIP_INCLUDE_DIRS)
