Skip to content

Commit

Permalink
build: modify target_generate_xml_docs to add_xml_docs function
Browse files Browse the repository at this point in the history
  • Loading branch information
threeal committed Jul 10, 2023
1 parent 34a309e commit bee807a
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 49 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,11 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3.5.3

- name: Configure and build documentation
- name: Configure project
uses: threeal/cmake-action@v1.2.0
with:
source-dir: ${{ matrix.package }}
options: BUILD_DOCS=ON
run-build: true

- name: Build documentation
run: cmake --build ${{ matrix.package }}/build --target docs
4 changes: 2 additions & 2 deletions error/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)

# Build XML documentation
if(BUILD_DOCS)
include(cmake/target_generate_xml_docs.cmake)
target_generate_xml_docs(error)
include(cmake/add_xml_docs.cmake)
add_xml_docs(docs include/error/error.hpp)
endif()
endif()
30 changes: 30 additions & 0 deletions error/cmake/add_xml_docs.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# A function that generates XML documentation from the specified source files.
function(add_xml_docs TARGET_NAME)
# Try to install Doxygen if not found
find_program(DOXYGEN_PROGRAM doxygen)
if(NOT DOXYGEN_PROGRAM)
find_program(APT_GET_PROGRAM apt-get)
if(APT_GET_PROGRAM)
message(STATUS "Doxygen could not be found, installing...")
execute_process(COMMAND ${APT_GET_PROGRAM} install -y doxygen)
endif()

find_program(BREW_PROGRAM brew)
if(BREW_PROGRAM)
message(STATUS "Doxygen could not be found, installing...")
execute_process(COMMAND ${BREW_PROGRAM} install doxygen)
endif()
endif()

# Try to find Doxygen
find_package(Doxygen)
if(DOXYGEN_FOUND)
# Configure Doxygen to generate XML documentation
set(DOXYGEN_GENERATE_HTML NO)
set(DOXYGEN_GENERATE_XML YES)
set(DOXYGEN_XML_OUTPUT ${TARGET_NAME})

# Generate XML documentation for the target
doxygen_add_docs(${TARGET_NAME} ${ARGN} USE_STAMP_FILE)
endif()
endfunction()
45 changes: 0 additions & 45 deletions error/cmake/target_generate_xml_docs.cmake

This file was deleted.

0 comments on commit bee807a

Please # to comment.