sc3dev/cmake/docs.cmake

53 lines
1.7 KiB
CMake

# Doxygen support for scsl.
set(DISABLE_DOXYGEN OFF CACHE BOOL "Don't use Doxygen for documentation.")
set(DISABLE_SCDOC OFF CACHE BOOL "Don't use scdoc to generate man pages.")
add_custom_target(manpages)
### Generate man pages from markdown ###
# md2man uses scdoc to produce a man page from a markdown document.
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/man
DESTINATION share)
macro(md2man source)
block()
set(SOURCE_MANPAGE)
set(SOURCE_SECTION)
string(REGEX REPLACE "^.+/([^/]+)\.md$" "\\1" SOURCE_MANPAGE ${source})
string(REGEX REPLACE "^.+/[^/]+\.([0-9])\.md$" "\\1" SOURCE_SECTION ${source})
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/man/man${SOURCE_SECTION})
configure_file(${source} ${SOURCE_MANPAGE}.scdoc)
add_custom_command(TARGET manpages
COMMAND mkdir -p man/man${SOURCE_SECTION} && scdoc < ${SOURCE_MANPAGE}.scdoc > man/man${SOURCE_SECTION}/${SOURCE_MANPAGE})
endblock()
endmacro()
md2man(./${PROJECT_NAME}-packager.1.md)
add_dependencies(${PROJECT_NAME}-packager manpages)
### Build documentation with Doxygen ###
#if (not DISABLE_DOXYGEN)
#find_package(Doxygen)
#if (${DOXYGEN_FOUND})
## prefer scdocs for manpages.
#set(DOXYGEN_GENERATE_MAN NO)
#set(DOXYGEN_GENERATE_LATEX YES)
#set(DOXYGEN_EXTRACT_ALL YES)
#set(DOXYGEN_USE_MDFILE_AS_MAINPAGE "docs/mainpage.md")
#message(STATUS "Doxygen found, building docs.")
#
#doxygen_add_docs(${PROJECT_NAME}_docs
# ${HEADER_FILES}
# ${SOURCE_FILES}
# USE_STAMP_FILE)
#add_dependencies(${PROJECT_NAME} ${PROJECT_NAME}_docs)
#install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html
# ${CMAKE_CURRENT_BINARY_DIR}/latex
# DESTINATION share/doc/${PROJECT_NAME}/doxygen)
#add_dependencies(${PROJECT_NAME}_docs manpages)
#endif () # DOXYGEN_FOUND?
#endif () # DISABLE_DOXYGEN?