# - Find the XERCESC includes and libraries.
SET(XERCESC_INCLUDE_PATH_DESCRIPTION "directory containing the XERCESC include files. E.g $ENV{HOME}/local/ or c:\\XERCESC")

SET(XERCESC_DIR_MESSAGE "Set the XERCESC_INCLUDE_DIR cmake cache entry or the XERCESC_ROOT environment variable to the ${XERCESC_INCLUDE_PATH_DESCRIPTION}")

SET(XERCESC_DIR_SEARCH $ENV{XERCESC_ROOT}) 

IF(UNIX)
  SET(XERCESC_DEFAULT_DIR_SEARCH "/usr/")
ENDIF(UNIX)

IF(XERCESC_DIR_SEARCH)
  FILE(TO_CMAKE_PATH ${XERCESC_DIR_SEARCH} XERCESC_DIR_SEARCH)
ENDIF(XERCESC_DIR_SEARCH)

SET(XERCESC_DIR_SEARCH ${XERCESC_DIR_SEARCH} ${XERCESC_DEFAULT_DIR_SEARCH} ${YARS_EXTERNAL_PACKAGES_PREFIX})

#
# Look for an installation.
#
FIND_PATH(XERCESC_ROOT_DIR NAMES include/xercesc/parsers/SAXParser.hpp PATHS 

  # Look in other places.
  ${XERCESC_DIR_SEARCH}

  # Help the user find it if we cannot.
  DOC "The ${XERCESC_INCLUDE_PATH_DESCRIPTION}"
)

SET(XERCESC_INCLUDE_DIR ${XERCESC_ROOT_DIR}/include)
SET(XERCESC_LIBRARY_DIR ${XERCESC_ROOT_DIR}/lib)

SET(XERCESC_INCLUDE_FILE ${XERCESC_INCLUDE_DIR}/xercesc/parsers/SAXParser.hpp)

FIND_LIBRARY(XERCESC_LIBRARY_FILE xerces-c
  ${XERCESC_ROOT_DIR}
  ${XERCESC_LIBRARY_DIR})


# Assume we didn't find it.
SET(XERCESC_FOUND 0)
IF(EXISTS ${XERCESC_LIBRARY_FILE})
  IF(EXISTS ${XERCESC_INCLUDE_FILE})
    SET(XERCESC_FOUND 1)
  ENDIF(EXISTS ${XERCESC_INCLUDE_FILE})
ENDIF(EXISTS ${XERCESC_LIBRARY_FILE})

IF(NOT XERCESC_FOUND)
  IF(NOT XERCESC_FIND_QUIETLY)
    MESSAGE(STATUS "XERCESC was not found. ${XERCESC_DIR_MESSAGE}")
  ELSE(NOT XERCESC_FIND_QUIETLY)
    IF(XERCESC_FIND_REQUIRED)
      MESSAGE(FATAL_ERROR "XERCESC was not found. ${XERCESC_DIR_MESSAGE}")
    ENDIF(XERCESC_FIND_REQUIRED)
  ENDIF(NOT XERCESC_FIND_QUIETLY)
ENDIF(NOT XERCESC_FOUND)

MARK_AS_ADVANCED(
  XERCESC_INCLUDE_DIR
  XERCESC_LIBRARY_DIR
  )
