Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,18 @@ cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
project(
InfoLogger
DESCRIPTION "O2 Logging library and services"
LANGUAGES CXX C
LANGUAGES NONE
)

# simplified build mode for doc only
if(ONLYDOC)
add_subdirectory(doc)
return()
endif()

# global compilation options
enable_language(C)
enable_language(CXX)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
Expand Down
77 changes: 57 additions & 20 deletions doc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,27 +1,64 @@
# @author Barthélémy von Haller
# Generate documentation

include(FindDoxygen)
# define doc build path
set(DOC_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/doc-build")

# define doc installation path
# ensures it ends with project name
if (NOT CMAKE_INSTALL_DOCDIR)
set(CMAKE_INSTALL_DOCDIR "doc")
endif()
if (NOT "${CMAKE_INSTALL_DOCDIR}" MATCHES "${PROJECT_NAME}$")
set(CMAKE_INSTALL_DOCDIR "${CMAKE_INSTALL_DOCDIR}/${PROJECT_NAME}")
endif()

if(NOT DOXYGEN_DOT_FOUND)
message(WARNING "Graphviz doesn't seem to be installed. Doxygen will not be able to generate graphs. Consider installing this package.")
endif(NOT DOXYGEN_DOT_FOUND)
# log doc build(install paths)
message(STATUS "Documentation will be built in ${DOC_BUILD_DIR}")
message(STATUS "Documentation will be installed in ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DOCDIR}")

# general files directly from source
install(
DIRECTORY .
TYPE DOC
FILES_MATCHING PATTERN "*.md" PATTERN "*.png"
)

# doxygen-generated files
include(FindDoxygen)
if (DOXYGEN_FOUND)
# Configure the doxygen config file with current settings
set("DOC_OUTPUT_DIR" "${CMAKE_CURRENT_BINARY_DIR}")
if(NOT DOXYGEN_DOT_FOUND)
message(WARNING "dot not found. Please install Graphviz.")
endif(NOT DOXYGEN_DOT_FOUND)

# configure the doxygen config file with current cmake settings
configure_file(doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/documentation-config.doxygen @ONLY)

# target doc
add_custom_target(doc
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/documentation-config.doxygen
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation using doxygen for ${PROJECT_NAME}
\n Output will be available in ${DOC_OUTPUT_DIR}/html" VERBATIM)

# installation
option(DOC_INSTALL "Install the documentation when calling \"make install\"" OFF)
if(DOC_INSTALL)
message(STATUS "Documentation will be installed but you *must* run `make doc`")
install(DIRECTORY ${DOC_OUTPUT_DIR}/html DESTINATION share/doc/${PROJECT_NAME} COMPONENT doc)
endif(DOC_INSTALL)
# build documentation with target "doc"
add_custom_target(
doc
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/documentation-config.doxygen
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation using doxygen for ${PROJECT_NAME}"
VERBATIM
DEPENDS doc-dir
)

# doxygen fails creating multi-level output directory, make sure it exists
add_custom_target(
doc-dir
COMMAND ${CMAKE_COMMAND} -E make_directory "${DOC_BUILD_DIR}"
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMENT "Create the doxygen output directory"
VERBATIM
)

# install generated files
install(
DIRECTORY ${DOC_BUILD_DIR}/html
TYPE DOC
OPTIONAL # because available only after "make doc"
)
else ()
message(WARNING "Doxygen not found")
endif (DOXYGEN_FOUND)

Loading