# - Find Asciidoc
# this module looks for asciidoc
#
# ASCIIDOC_EXECUTABLE - the full path to asciidoc
# ASCIIDOC_FOUND - If false, don't attempt to use asciidoc.

IF(NOT WIN32)
  FIND_PROGRAM(ASCIIDOC_EXECUTABLE
    asciidoc
  )
ELSE(NOT WIN32)
  FIND_PROGRAM(ASCIIDOC_PYTHON python)
  FIND_FILE(ASCIIDOC_PYFILE asciidoc.py
    PATHS
      c:/asciidoc
      ${ASCIIDOC_DIR}
  )
  IF(ASCIIDOC_PYTHON AND ASCIIDOC_PYFILE)
    SET(ASCIIDOC_EXECUTABLE ${ASCIIDOC_PYTHON} ${ASCIIDOC_PYFILE})
  ENDIF(ASCIIDOC_PYTHON AND ASCIIDOC_PYFILE)
ENDIF(NOT WIN32)

#MESSAGE(FATAL_ERROR "asciidoc exec: ${ASCIIDOC_EXECUTABLE}")

IF (NOT ASCIIDOC_EXECUTABLE)
  SET(ASCIIDOC_FOUND "NO" CACHE BOOL "ASCIIDOC found")
ELSE (NOT ASCIIDOC_EXECUTABLE)
  SET(ASCIIDOC_FOUND "YES" CACHE BOOL "ASCIIDOC found")
ENDIF (NOT ASCIIDOC_EXECUTABLE)

MARK_AS_ADVANCED(
  ASCIIDOC_EXECUTABLE
  ASCIIDOC_PYTHON
  ASCIIDOC_PYFILE
  ASCIIDOC_FOUND
)


IF (NOT ASCIIDOC_FOUND AND Asciidoc_FIND_REQUIRED)
  MESSAGE(FATAL_ERROR "Could not find asciidoc")
ENDIF (NOT ASCIIDOC_FOUND AND Asciidoc_FIND_REQUIRED)


