Skip to content

Commit

Permalink
cmake: Add docs build target
Browse files Browse the repository at this point in the history
  • Loading branch information
hebasto committed Apr 23, 2024
1 parent f9b43f7 commit caebe45
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 4 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,7 @@ endif()

add_subdirectory(src)
add_subdirectory(test)
add_subdirectory(doc)

include(cmake/tests.cmake)

Expand Down
32 changes: 32 additions & 0 deletions doc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright (c) 2024-present The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or https://opensource.org/license/mit/.

find_package(Doxygen COMPONENTS dot)

if(DOXYGEN_FOUND)
set(doxyfile ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
configure_file(Doxyfile.in ${doxyfile})

# In CMake 3.27, The FindDoxygen module's doxygen_add_docs()
# command gained a CONFIG_FILE option to specify a custom doxygen
# configuration file.
# TODO: Consider using it.
set(stampfile ${CMAKE_CURRENT_BINARY_DIR}/.stamp)
add_custom_command(
OUTPUT ${stampfile}
COMMAND Doxygen::doxygen ${doxyfile}
COMMAND ${CMAKE_COMMAND} -E touch ${stampfile}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
DEPENDS ${doxyfile}
COMMENT "Generating developer documentation"
VERBATIM
)
add_custom_target(docs
DEPENDS ${stampfile}
)
else()
add_custom_target(docs
COMMAND ${CMAKE_COMMAND} -E echo "error: doxygen not found"
)
endif()
2 changes: 1 addition & 1 deletion doc/Doxyfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ PROJECT_LOGO = doc/bitcoin_logo_doxygen.png
# entered, it will be relative to the location where doxygen was started. If
# left blank the current directory will be used.

OUTPUT_DIRECTORY = doc/doxygen
OUTPUT_DIRECTORY = @PROJECT_BINARY_DIR@/doxygen

# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub-
# directories (in 2 levels) under the output directory of each output format and
Expand Down
6 changes: 3 additions & 3 deletions doc/developer-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -339,11 +339,11 @@ Recommendations:

### Generating Documentation

The documentation can be generated with `make docs` and cleaned up with `make
clean-docs`. The resulting files are located in `doc/doxygen/html`; open
The documentation can be generated with `cmake --build <build_dir> --target docs`.
The resulting files are located in `<build_dir>/doxygen/html`; open
`index.html` in that directory to view the homepage.

Before running `make docs`, you'll need to install these dependencies:
Before building the `docs` target, you'll need to install these dependencies:

Linux: `sudo apt install doxygen graphviz`

Expand Down

0 comments on commit caebe45

Please sign in to comment.