Skip to content

Commit c5bd044

Browse files
committed
cmake doc cleanup
1 parent 3b25d1f commit c5bd044

File tree

3 files changed

+64
-26
lines changed

3 files changed

+64
-26
lines changed

CMakeLists.txt

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@ project(
1313
LANGUAGES CXX C
1414
)
1515

16+
# default install dirs
17+
include(GNUInstallDirs)
18+
19+
# add subdirectories
20+
add_subdirectory(doc)
21+
# stop immediately for easy building of doc only
22+
if(ONLYDOC)
23+
return()
24+
endif()
25+
1626
# global compilation options
1727
set(CMAKE_CXX_STANDARD 14)
1828
set(CMAKE_CXX_STANDARD_REQUIRED ON)
@@ -23,15 +33,11 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
2333
# build-time binaries
2434
set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin")
2535
# installation
26-
include(GNUInstallDirs)
2736
set(CMAKE_INSTALL_LIBDIR lib)
2837

2938
# add local modules directory
3039
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
3140

32-
# add subdirectories
33-
add_subdirectory(doc)
34-
3541
# dependencies to build the InfoLogger components
3642
# NB: cmake/InfoLoggerConfig.cmake defines dependencies for clients using the library
3743
#find_package(Common REQUIRED)

doc/CMakeLists.txt

Lines changed: 53 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,60 @@
1-
# @author Barthélémy von Haller
2-
31
include(FindDoxygen)
42

5-
if(NOT DOXYGEN_DOT_FOUND)
6-
message(WARNING "Graphviz doesn't seem to be installed. Doxygen will not be able to generate graphs. Consider installing this package.")
7-
endif(NOT DOXYGEN_DOT_FOUND)
3+
# put doc in a subdirectory with project name, if not already set so
4+
if (NOT CMAKE_INSTALL_DOCDIR)
5+
set(CMAKE_INSTALL_DOCDIR "doc")
6+
endif()
7+
if (NOT "${CMAKE_INSTALL_DOCDIR}" MATCHES "${PROJECT_NAME}$")
8+
set(CMAKE_INSTALL_DOCDIR "${CMAKE_INSTALL_DOCDIR}/${PROJECT_NAME}")
9+
endif()
10+
set(DOC_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_DOCDIR}")
11+
12+
# log doc build(install paths)
13+
message(STATUS "Documentation will be generated in ${DOC_OUTPUT_DIR}")
14+
message(STATUS "Documentation will be installed in ${CMAKE_INSTALL_DOCDIR}")
815

16+
# general files directly from source
17+
install(
18+
DIRECTORY .
19+
TYPE DOC
20+
FILES_MATCHING PATTERN "*.md" PATTERN "*.png"
21+
)
22+
23+
# doxygen-generated files
924
if (DOXYGEN_FOUND)
10-
# Configure the doxygen config file with current settings
11-
set("DOC_OUTPUT_DIR" "${CMAKE_CURRENT_BINARY_DIR}")
25+
if(NOT DOXYGEN_DOT_FOUND)
26+
message(WARNING "dot not found. Please install Graphviz.")
27+
endif(NOT DOXYGEN_DOT_FOUND)
28+
29+
# configure the doxygen config file with current cmake settings
1230
configure_file(doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/documentation-config.doxygen @ONLY)
1331

14-
# target doc
15-
add_custom_target(doc
16-
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/documentation-config.doxygen
17-
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
18-
COMMENT "Generating API documentation using doxygen for ${PROJECT_NAME}
19-
\n Output will be available in ${DOC_OUTPUT_DIR}/html" VERBATIM)
20-
21-
# installation
22-
option(DOC_INSTALL "Install the documentation when calling \"make install\"" OFF)
23-
if(DOC_INSTALL)
24-
message(STATUS "Documentation will be installed but you *must* run `make doc`")
25-
install(DIRECTORY ${DOC_OUTPUT_DIR}/html DESTINATION share/doc/${PROJECT_NAME} COMPONENT doc)
26-
endif(DOC_INSTALL)
32+
# build documentation with target "doc"
33+
add_custom_target(
34+
doc
35+
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/documentation-config.doxygen
36+
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
37+
COMMENT "Generating API documentation using doxygen for ${PROJECT_NAME}"
38+
VERBATIM
39+
DEPENDS doc-dir
40+
)
41+
42+
# doxygen fails creating multi-level output directory, make sure it exists
43+
add_custom_target(
44+
doc-dir
45+
COMMAND ${CMAKE_COMMAND} -E make_directory "${DOC_OUTPUT_DIR}"
46+
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
47+
COMMENT "Create the doxygen output directory"
48+
VERBATIM
49+
)
50+
51+
# install generated files
52+
install(
53+
DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_DOCDIR}/html
54+
TYPE DOC
55+
OPTIONAL # because available only after "make doc"
56+
)
57+
else (DO)
58+
message(WARNING "Doxygen not found")
2759
endif (DOXYGEN_FOUND)
60+

doc/doxyfile.in

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,6 @@ WARN_LOGFILE =
734734
# Note: If this tag is empty the current directory is searched.
735735

736736
INPUT = "@PROJECT_SOURCE_DIR@/include" \
737-
"@PROJECT_BINARY_DIR@/include" \
738737
"@PROJECT_SOURCE_DIR@/src" \
739738
"@PROJECT_SOURCE_DIR@/doc"
740739

@@ -2055,7 +2054,7 @@ DOT_NUM_THREADS = 0
20552054
# The default value is: Helvetica.
20562055
# This tag requires that the tag HAVE_DOT is set to YES.
20572056

2058-
DOT_FONTNAME = FreeSans
2057+
#DOT_FONTNAME = FreeSans
20592058

20602059
# The DOT_FONTSIZE tag can be used to set the size (in points) of the font of
20612060
# dot graphs.

0 commit comments

Comments
 (0)