Skip to content

Commit 2ee330e

Browse files
committed
build: modify target_generate_xml_docs to add_xml_docs function
1 parent 34a309e commit 2ee330e

File tree

3 files changed

+35
-47
lines changed

3 files changed

+35
-47
lines changed

error/CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,10 @@ if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
6060

6161
# Build XML documentation
6262
if(BUILD_DOCS)
63-
include(cmake/target_generate_xml_docs.cmake)
64-
target_generate_xml_docs(error)
63+
include(cmake/add_xml_docs.cmake)
64+
add_xml_docs(error_docs include/error/error.hpp)
65+
66+
add_custom_target(docs)
67+
add_dependencies(docs error_docs)
6568
endif()
6669
endif()

error/cmake/add_xml_docs.cmake

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# A function that generates XML documentation from the specified source files.
2+
function(add_xml_docs TARGET_NAME)
3+
# Try to install Doxygen if not found
4+
find_program(DOXYGEN_PROGRAM doxygen)
5+
if(NOT DOXYGEN_PROGRAM)
6+
find_program(APT_GET_PROGRAM apt-get)
7+
if(APT_GET_PROGRAM)
8+
message(STATUS "Doxygen could not be found, installing...")
9+
execute_process(COMMAND ${APT_GET_PROGRAM} install -y doxygen)
10+
endif()
11+
12+
find_program(BREW_PROGRAM brew)
13+
if(BREW_PROGRAM)
14+
message(STATUS "Doxygen could not be found, installing...")
15+
execute_process(COMMAND ${BREW_PROGRAM} install doxygen)
16+
endif()
17+
endif()
18+
19+
# Try to find Doxygen
20+
find_package(Doxygen)
21+
if(DOXYGEN_FOUND)
22+
# Configure Doxygen to generate XML documentation
23+
set(DOXYGEN_GENERATE_HTML NO)
24+
set(DOXYGEN_GENERATE_XML YES)
25+
set(DOXYGEN_XML_OUTPUT ${TARGET_NAME})
26+
27+
# Generate XML documentation for the target
28+
doxygen_add_docs(${TARGET_NAME} ${ARGN} USE_STAMP_FILE)
29+
endif()
30+
endfunction()

error/cmake/target_generate_xml_docs.cmake

Lines changed: 0 additions & 45 deletions
This file was deleted.

0 commit comments

Comments
 (0)