Add the doxygen cmake file to the CMake Project

Make the docs its own target instead of a project. Dont add the
new docs target to ALL. Add an option to disable generating the
docs.
Update doxygen_awesome to v2.4.2.
Update README to reflect new changes.
This commit is contained in:
Cayleb-Ordo 2025-02-19 21:45:43 +01:00
parent c5dffb0dc9
commit 853472586f
3 changed files with 65 additions and 53 deletions

View file

@ -4,6 +4,7 @@ project(0ad VERSION 0.29.0)
# Available Options # Available Options
option(android "Use non-working Android cross-compiling mode") option(android "Use non-working Android cross-compiling mode")
option(build-docs "Enable building the doxygen documentation(requires Network access)")
option(coverage "Enable code coverage data collection (GCC only)") option(coverage "Enable code coverage data collection (GCC only)")
option(gles "Use non-working OpenGL ES 2.0 mode") option(gles "Use non-working OpenGL ES 2.0 mode")
option(jenkins-tests "Configure CxxTest to use the XmlPrinter runner which produces Jenkins-compatible output") option(jenkins-tests "Configure CxxTest to use the XmlPrinter runner which produces Jenkins-compatible output")
@ -144,3 +145,8 @@ include(0ad-BuildFlags)
if(CMAKE_SYSTEM_NAME STREQUAL "Windows") if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
include(SetupWindowsLibs) include(SetupWindowsLibs)
endif() endif()
# Add doxygen target
if(build-docs)
add_subdirectory(${CMAKE_SOURCE_DIR}/docs/doxygen)
endif()

View file

@ -6,7 +6,11 @@
## Building the Doxygen documentation ## Building the Doxygen documentation
To generate the Doxygen documentation: run "cmake -S . -B output && cmake --build output". To generate the Doxygen documentation:
```console
cmake -S 0ad/rootdir -B output && cmake --build output --target docs
```
If you build the documentation with cmake, the output is located in the folder html inside your If you build the documentation with cmake, the output is located in the folder html inside your
specified build directory. specified build directory.

View file

@ -1,6 +1,4 @@
cmake_minimum_required(VERSION 3.18.4...3.28.0) cmake_minimum_required(VERSION 3.25.1...4.0.0)
project(Pyrogenesis DESCRIPTION "Pyrogenesis, a RTS Engine" LANGUAGES NONE)
# Check if Doxygen and graphviz are installed. # Check if Doxygen and graphviz are installed.
find_package(Doxygen 1.9.1 REQUIRED dot) find_package(Doxygen 1.9.1 REQUIRED dot)
@ -9,9 +7,10 @@ if(DOXYGEN_FOUND)
include(FetchContent) include(FetchContent)
message(STATUS "Fetching doxygen_awesome_css")
FetchContent_Declare(doxygen_awesome_css FetchContent_Declare(doxygen_awesome_css
GIT_REPOSITORY https://github.com/jothepro/doxygen-awesome-css GIT_REPOSITORY https://github.com/jothepro/doxygen-awesome-css
GIT_TAG v2.3.3 GIT_TAG v2.4.2
SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/styling SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/styling
) )
FetchContent_MakeAvailable(doxygen_awesome_css) FetchContent_MakeAvailable(doxygen_awesome_css)
@ -27,6 +26,8 @@ if(DOXYGEN_FOUND)
endif() endif()
# Doxygen Configuration. # Doxygen Configuration.
set(DOXYGEN_PROJECT_NAME "Pyrogenesis")
set(DOXYGEN_PROJECT_BRIEF "Pyrogenesis, a RTS Engine")
if(CURRENT_BRANCH) if(CURRENT_BRANCH)
set(DOXYGEN_PROJECT_NUMBER ${CURRENT_BRANCH}) set(DOXYGEN_PROJECT_NUMBER ${CURRENT_BRANCH})
else() else()
@ -35,9 +36,9 @@ if(DOXYGEN_FOUND)
set(DOXYGEN_PROJECT_LOGO ${CMAKE_CURRENT_SOURCE_DIR}/pyrogenesis.png) set(DOXYGEN_PROJECT_LOGO ${CMAKE_CURRENT_SOURCE_DIR}/pyrogenesis.png)
set(DOXYGEN_TAB_SIZE 4) set(DOXYGEN_TAB_SIZE 4)
set(DOXYGEN_EXCLUDE_PATTERNS */.svn* */tests/test_*) set(DOXYGEN_EXCLUDE_PATTERNS */.svn* */tests/test_*)
set(DOXYGEN_INCLUDE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../source) set(DOXYGEN_INCLUDE_PATH ${CMAKE_SOURCE_DIR}/source)
set(DOXYGEN_EXAMPLE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../source) set(DOXYGEN_EXAMPLE_PATH ${CMAKE_SOURCE_DIR}/source)
set(DOXYGEN_EXCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/../../source/tools ${CMAKE_CURRENT_SOURCE_DIR}/../../source/third_party) set(DOXYGEN_EXCLUDE ${CMAKE_SOURCE_DIR}/source/tools ${CMAKE_SOURCE_DIR}/source/third_party)
set(DOXYGEN_GENERATE_TREEVIEW YES) set(DOXYGEN_GENERATE_TREEVIEW YES)
set(DOXYGEN_HTML_EXTRA_STYLESHEET ${doxygen_awesome_css_SOURCE_DIR}/doxygen-awesome.css ${CMAKE_CURRENT_SOURCE_DIR}/style.css) set(DOXYGEN_HTML_EXTRA_STYLESHEET ${doxygen_awesome_css_SOURCE_DIR}/doxygen-awesome.css ${CMAKE_CURRENT_SOURCE_DIR}/style.css)
set(DOXYGEN_JAVADOC_AUTOBRIEF YES) set(DOXYGEN_JAVADOC_AUTOBRIEF YES)
@ -54,11 +55,12 @@ if(DOXYGEN_FOUND)
set(DOXYGEN_EXPAND_AS_DEFINED DEFAULT_COMPONENT_ALLOCATOR DEFAULT_SCRIPT_WRAPPER DEFAULT_INTERFACE_WRAPPER DEFAULT_MESSAGE_IMPL MESSAGE INTERFACE COMPONENT GUISTDTYPE) set(DOXYGEN_EXPAND_AS_DEFINED DEFAULT_COMPONENT_ALLOCATOR DEFAULT_SCRIPT_WRAPPER DEFAULT_INTERFACE_WRAPPER DEFAULT_MESSAGE_IMPL MESSAGE INTERFACE COMPONENT GUISTDTYPE)
set(DOXYGEN_WARN_LOGFILE doxygen.log) set(DOXYGEN_WARN_LOGFILE doxygen.log)
doxygen_add_docs(${CMAKE_PROJECT_NAME} doxygen_add_docs(docs
${CMAKE_CURRENT_SOURCE_DIR}/../../source ${CMAKE_SOURCE_DIR}/source
${CMAKE_CURRENT_SOURCE_DIR}/mainpage.dox ${CMAKE_CURRENT_SOURCE_DIR}/mainpage.dox
${CMAKE_CURRENT_SOURCE_DIR}/../../LICENSE.md ${CMAKE_SOURCE_DIR}/LICENSE.md
ALL) COMMENT "Creating Doxygen for the engine."
)
else() else()
message(SEND_ERROR "Make sure Doxygen is installed and usable") message(SEND_ERROR "Make sure Doxygen is installed and usable")
endif() endif()