Asciidoc is a really useful and sensible way of allowing people to write documentation, in that the plain text source code is nearly as readable as the generated output. The following is a CMake file to allow for conversion of text input files into asciidoc generated output files
PROJECT(Document)
FIND_PACKAGE(Asciidoc)
IF(ASCIIDOC_FOUND)
FILE(GLOB _docfiles *.txt)
FOREACH(_file ${_docfiles})
GET_FILENAME_COMPONENT(_file_we ${_file} NAME_WE)
SET(_in "${_file_we}")
SET(_out "${_file_we}.html")
IF (NOT "${_in}" STREQUAL "CMakeLists")
ADD_CUSTOM_COMMAND(
OUTPUT "${_out}"
COMMAND ${ASCIIDOC_EXECUTABLE} -a toc -o ${_out} ${_file}
DEPENDS ${_file}
COMMENT "Asciidoc ${_in}"
)
ADD_CUSTOM_TARGET(${_in} ALL echo
DEPENDS "${_out}"
)
ENDIF (NOT "${_in}" STREQUAL "CMakeLists")
ENDFOREACH(_file)
ENDIF(ASCIIDOC_FOUND)
And it needs the following FindAsciidoc.cmake file available
# - Find Asciidoc
# this module looks for asciidoc
#
# ASCIIDOC_EXECUTABLE - the full path to asciidoc
# ASCIIDOC_FOUND - If false, don't attempt to use asciidoc.
FIND_PROGRAM(ASCIIDOC_EXECUTABLE
asciidoc
)
MARK_AS_ADVANCED(
ASCIIDOC_EXECUTABLE
)
IF (NOT ASCIIDOC_EXECUTABLE)
SET(ASCIIDOC_FOUND "NO")
ELSE (NOT ASCIIDOC_EXECUTABLE)
SET(ASCIIDOC_FOUND "YES")
ENDIF (NOT ASCIIDOC_EXECUTABLE)
IF (NOT ASCIIDOC_FOUND AND Asciidoc_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find asciidoc")
ENDIF (NOT ASCIIDOC_FOUND AND Asciidoc_FIND_REQUIRED)