# This file is part of the Owl Positioning System (OwlPS) project. # It is subject to the copyright notice and license terms in the # COPYRIGHT.t2t file found in the top-level directory of this # distribution and at # http://code.lm7.fr/p/owlps/source/tree/master/COPYRIGHT.t2t # No part of the OwlPS Project, including this file, may be copied, # modified, propagated, or distributed except according to the terms # contained in the COPYRIGHT.t2t file; the COPYRIGHT.t2t file must be # distributed along with this file, either separately or by replacing # this notice by the COPYRIGHT.t2t file's contents. # Make sure txt2tags is available find_package(Txt2tags) if (NOT TXT2TAGS_FOUND) message(WARNING "Dependency missing to generate OwlPS' documentation: txt2tags") return() endif() ### Man pages ### set(MAN_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/man") set(PREPROC_MAN ./preproc-man.sh) add_custom_target(doc ALL true) function(add_manpage PAGENAME SECTION) set(OUTPUT_DIRECTORY "${MAN_OUTPUT_DIRECTORY}/man${SECTION}") set(SOURCE ${PAGENAME}.t2t) set(TARGETNAME ${PAGENAME}.${SECTION}) set(TARGET "${OUTPUT_DIRECTORY}/${TARGETNAME}") # Create the output directory # Note: this is done only when first calling cmake and when rebuilding # cache; it would be nice if it could be called every time, but there # doesn't seem to be any simple solution. file(MAKE_DIRECTORY "${OUTPUT_DIRECTORY}") # Command to generate the man page add_custom_command( OUTPUT "${TARGET}" COMMAND "${PREPROC_MAN}" "${SOURCE}" | "${TXT2TAGS_EXECUTABLE}" -q --infile=- --outfile="${TARGET}" -t man DEPENDS "${SOURCE}" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" COMMENT "Generating ${TARGETNAME}") # Set up the target add_custom_target(${TARGETNAME} true DEPENDS "${TARGET}") # Add the target to the "doc" meta-target add_dependencies(doc "${TARGETNAME}") endfunction() add_manpage(owlps 7) add_manpage(owlps-architecture 7) add_manpage(owlps-deployment 7) add_manpage(owlps-client 1) ### Doxygen-generated man pages ### if (NOT DOXYGEN_FOUND) message(WARNING "Couldn't find Doxygen: disabling generation of Doxygen-based man pages") return() endif() # Base output directory for Doxygen (it will append "man" for the # man pages, "html" for the HTML output, etc.) set(DOXYGEN_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}") # Section of the man pages we generate set(SECTION 3) # Final output directory (as assembled by Doxygen) set(OUTPUT_DIRECTORY "${DOXYGEN_OUTPUT_DIRECTORY}/man/man${SECTION}") # Output files set(DOXYGEN_MANPAGES "${OUTPUT_DIRECTORY}/owlps.h.${SECTION}" "${OUTPUT_DIRECTORY}/owlps-client.h.${SECTION}" "${OUTPUT_DIRECTORY}/owlps-resultreader.h.${SECTION}") # Doxygen configuration file name set(DOXYFILE Doxyfile) add_custom_command( OUTPUT ${DOXYGEN_MANPAGES} COMMAND DOXYGEN_OUTPUT_DIRECTORY=${DOXYGEN_OUTPUT_DIRECTORY} DOXYGEN_MAN_EXTENSION=.${SECTION} OWLPS_VERSION=${OWLPS_VERSION} "${DOXYGEN_EXECUTABLE}" "${DOXYFILE}" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" COMMENT "Generating Doxygen-based man pages") # Target to clean the files generated by Doxygen that we don't want # (so-called "directory references"). This cannot be done with CMake's # file() commands because it has to be run every time the target is # built, and you cannot use CMake functions in a custom target or # command. add_custom_target(clean_doxygen_garbage COMMAND rm -f "${OUTPUT_DIRECTORY}/_*_owlps_libowlps*_.${SECTION}") # Set up the target add_custom_target(doc_doxygen true DEPENDS ${DOXYGEN_MANPAGES}) # Add the target to the "doc" meta-target add_dependencies(doc doc_doxygen clean_doxygen_garbage)