Skip to content

Commit d88e03c

Browse files
committed
cmake: Add docs build target
1 parent 6640654 commit d88e03c

File tree

4 files changed

+30
-4
lines changed

4 files changed

+30
-4
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,7 @@ endif()
543543

544544
add_subdirectory(src)
545545
add_subdirectory(test)
546+
add_subdirectory(doc)
546547

547548
include(cmake/tests.cmake)
548549

doc/CMakeLists.txt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Copyright (c) 2024-present The Bitcoin Core developers
2+
# Distributed under the MIT software license, see the accompanying
3+
# file COPYING or https://opensource.org/license/mit/.
4+
5+
find_package(Doxygen COMPONENTS dot)
6+
7+
if(DOXYGEN_FOUND)
8+
set(doxyfile ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
9+
configure_file(Doxyfile.in ${doxyfile})
10+
11+
# In CMake 3.27, The FindDoxygen module's doxygen_add_docs()
12+
# command gained a CONFIG_FILE option to specify a custom doxygen
13+
# configuration file.
14+
# TODO: Consider using it.
15+
add_custom_target(docs
16+
COMMAND Doxygen::doxygen ${doxyfile}
17+
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
18+
COMMENT "Generating developer documentation"
19+
VERBATIM USES_TERMINAL
20+
)
21+
else()
22+
add_custom_target(docs
23+
COMMAND ${CMAKE_COMMAND} -E echo "Error: Doxygen not found"
24+
)
25+
endif()

doc/Doxyfile.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ PROJECT_LOGO = doc/bitcoin_logo_doxygen.png
5858
# entered, it will be relative to the location where doxygen was started. If
5959
# left blank the current directory will be used.
6060

61-
OUTPUT_DIRECTORY = doc/doxygen
61+
OUTPUT_DIRECTORY = @PROJECT_BINARY_DIR@/doc/doxygen
6262

6363
# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub-
6464
# directories (in 2 levels) under the output directory of each output format and

doc/developer-notes.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,11 +339,11 @@ Recommendations:
339339

340340
### Generating Documentation
341341

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

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

348348
Linux: `sudo apt install doxygen graphviz`
349349

0 commit comments

Comments
 (0)