# Try to find the HTML Tidy lib
#
#  LIBTIDY_FOUND        - true if LIBTIDY was found
#  LIBTIDY_INCLUDE_DIRS - Directory to include to get LIBTIDY headers
#                         Note: always include LIBTIDY headers as e.g.,
#                         tidy/tidy.h
#  LIBTIDY_LIBRARIES    - Libraries to link against for the LIBTIDY
#


IF (LIBTIDY_INCLUDE_DIR)
  SET(LibTidy_FIND_QUIETLY TRUE)
endif (LIBTIDY_INCLUDE_DIR)

# Look for the header file.
FIND_PATH(LIBTIDY_INCLUDE_DIR tidy.h PATH_SUFFIXES tidy)
MARK_AS_ADVANCED(LIBTIDY_INCLUDE_DIR)

# Look for the library.
FIND_LIBRARY(LIBTIDY_LIBRARY NAMES tidy)
MARK_AS_ADVANCED(LIBTIDY_LIBRARY)

# INCLUDE(FindPackageHandleStandardArgs)
# only available in cmake > 2.6
# FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBTIDY DEFAULT_MSG LIBTIDY_INCLUDE_DIR LIBTIDY_LIBRARY)
#IF (LIBTIDY_FOUND)
#  SET(LIBTIDY_LIBRARIES ${LIBTIDY_LIBRARY})
#  SET(LIBTIDY_INCLUDE_DIRS ${LIBTIDY_INCLUDE_DIR})
#ELSE (LIBTIDY_FOUND)
#  SET(LIBTIDY_LIBRARIES)
#  SET(LIBTIDY_INCLUDE_DIRS)
#ENDIF (LIBTIDY_FOUND)
IF (LIBTIDY_INCLUDE_DIR AND LIBTIDY_LIBRARY)
  SET(LIBTIDY_FOUND 1)
  SET(LIBTIDY_LIBRARIES ${LIBTIDY_LIBRARY})
  SET(LIBTIDY_INCLUDE_DIRS ${LIBTIDY_INCLUDE_DIR})
  MESSAGE("-- Found libtidy library -- " ${LIBTIDY_LIBRARY})
  MESSAGE("-- Found libtidy include path -- " ${LIBTIDY_INCLUDE_DIR})
ELSE (LIBTIDY_INCLUDE_DIR AND LIBTIDY_LIBRARY)
  SET(LIBTIDY_FOUND 0)
  SET(LIBTIDY_LIBRARIES)
  SET(LIBTIDY_INCLUDE_DIRS)
ENDIF (LIBTIDY_INCLUDE_DIR AND LIBTIDY_LIBRARY)

