[doc] CMake: install man pages

This commit is contained in:
Matteo Cypriani 2013-09-23 16:56:22 -04:00
parent 703e78ff1a
commit d4cd2e6a63
1 changed files with 58 additions and 50 deletions

View File

@ -130,57 +130,65 @@ endif()
if (NOT DOXYGEN_FOUND)
message(WARNING
"Couldn't find Doxygen: disabling generation of Doxygen-based man pages")
return()
else()
# 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}")
# Corresponding input files (note that we cannot use this list as input
# for Doxygen, due to space protection issues, therefore it is
# duplicated in the Doxyfile)
set(INPUT_FILES
${CMAKE_SOURCE_DIR}/libowlps/owlps.h
${CMAKE_SOURCE_DIR}/libowlps/libowlps.c
${CMAKE_SOURCE_DIR}/libowlps-client/owlps-client.h
${CMAKE_SOURCE_DIR}/libowlps-client/libowlps-client.c
${CMAKE_SOURCE_DIR}/libowlps-resultreader/owlps-resultreader.h
${CMAKE_SOURCE_DIR}/libowlps-resultreader/libowlps-resultreader.c)
# 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}"
DEPENDS ${INPUT_FILES}
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 ${CMAKE_COMMAND} -E remove "${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. The fact that "doc" depends
# only on "clean_doxygen_garbage" and that the latter depends on
# "doc_doxygen" guaranties that the garbage are actually cleaned *after*
# they are generated.
add_dependencies(clean_doxygen_garbage doc_doxygen)
add_dependencies(doc clean_doxygen_garbage)
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}")
# Corresponding input files (note that we cannot use this list as input
# for Doxygen, due to space protection issues, therefore it is
# duplicated in the Doxyfile)
set(INPUT_FILES
${CMAKE_SOURCE_DIR}/libowlps/owlps.h
${CMAKE_SOURCE_DIR}/libowlps/libowlps.c
${CMAKE_SOURCE_DIR}/libowlps-client/owlps-client.h
${CMAKE_SOURCE_DIR}/libowlps-client/libowlps-client.c
${CMAKE_SOURCE_DIR}/libowlps-resultreader/owlps-resultreader.h
${CMAKE_SOURCE_DIR}/libowlps-resultreader/libowlps-resultreader.c)
### Installation ###
# 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}"
DEPENDS ${INPUT_FILES}
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 ${CMAKE_COMMAND} -E remove "${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. The fact that "doc" depends
# only on "clean_doxygen_garbage" and that the latter depends on
# "doc_doxygen" guaranties that the garbage are actually cleaned *after*
# they are generated.
add_dependencies(clean_doxygen_garbage doc_doxygen)
add_dependencies(doc clean_doxygen_garbage)
install(
DIRECTORY ${MAN_OUTPUT_DIRECTORY}
DESTINATION share)