Skip to content

Commit abc77b9

Browse files
Enable doxygen documentation in the cmake build system (#1281)
1 parent b4e119e commit abc77b9

File tree

4 files changed

+41
-5
lines changed

4 files changed

+41
-5
lines changed

CMakeLists.txt

+10-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ project(
1313

1414
get_directory_property(hasParent PARENT_DIRECTORY)
1515
if(hasParent)
16-
# Unset flags that come from Parent (ie UFS or other coupled build)
16+
# Unset flags that come from Parent (ie UFS or other coupled build)
1717
# for potential (-r8/-r4) conflict
1818
set(CMAKE_Fortran_FLAGS "")
1919
set(CMAKE_C_FLAGS "")
@@ -22,8 +22,9 @@ endif()
2222

2323
set(MULTI_ESMF OFF CACHE BOOL "Build ww3_multi_esmf library")
2424
set(NETCDF ON CACHE BOOL "Build NetCDF programs (requires NetCDF)")
25-
set(ENDIAN "BIG" CACHE STRING "Endianness of unformatted output files. Valid values are 'BIG', 'LITTLE', 'NATIVE'.")
25+
set(ENDIAN "BIG" CACHE STRING "Endianness of unformatted output files. Valid values are 'BIG', 'LITTLE', 'NATIVE'.")
2626
set(EXCLUDE_FIND "" CACHE STRING "Don't try and search for these libraries (assumd to be handled by the compiler/wrapper)")
27+
set(ENABLE_DOCS OFF CACHE BOOL "Enable building of doxygen generated documentation")
2728

2829
# make sure all "exclude_find" entries are lower case
2930
list(TRANSFORM EXCLUDE_FIND TOLOWER)
@@ -59,6 +60,13 @@ endif()
5960

6061
add_subdirectory(model)
6162

63+
# Turn on doxygen documentation
64+
if (ENABLE_DOCS)
65+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/docs/cmake")
66+
include(EnableDoxygen)
67+
add_subdirectory(docs)
68+
endif()
69+
6270
# Turn on unit testing.
6371
#include(CTest)
6472
#if(BUILD_TESTING)

docs/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
EnableDoxygen(docs)

docs/Doxyfile.in

+3-3
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ PROJECT_LOGO =
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 = docs
61+
OUTPUT_DIRECTORY = @doc_output@
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
@@ -829,7 +829,7 @@ WARN_LOGFILE =
829829
# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
830830
# Note: If this tag is empty the current directory is searched.
831831

832-
INPUT = model/src
832+
INPUT = @src_input@
833833

834834
# This tag can be used to specify the character encoding of the source files
835835
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
@@ -2285,7 +2285,7 @@ CLASS_DIAGRAMS = NO
22852285
# DIA_PATH tag allows you to specify the directory where the dia binary resides.
22862286
# If left empty dia is assumed to be found in the default search path.
22872287

2288-
DIA_PATH =
2288+
DIA_PATH =
22892289

22902290
# If set to YES the inheritance and collaboration graphs will hide inheritance
22912291
# and usage relations if the target is undocumented or is not a class.

docs/cmake/EnableDoxygen.cmake

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Doxygen documentation- Matt Masarik 24-Jul-2024.
2+
function(EnableDoxygen outdir)
3+
find_package(Doxygen REQUIRED)
4+
if (NOT DOXYGEN_FOUND)
5+
add_custom_target(enable_docs
6+
COMMAND false
7+
COMMENT "Doxygen not found")
8+
return()
9+
endif()
10+
11+
set(src_input "${CMAKE_SOURCE_DIR}/model/src")
12+
set(doc_output "${CMAKE_BINARY_DIR}/${outdir}")
13+
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/${outdir}/html)
14+
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/docs/Doxyfile.in
15+
${CMAKE_BINARY_DIR}/${outdir}/Doxyfile @ONLY)
16+
set(DOXYGEN_GENERATE_HTML YES)
17+
set(DOXYGEN_QUIET YES)
18+
add_custom_target(enable_docs
19+
COMMAND
20+
${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/${outdir}/Doxyfile
21+
WORKING_DIRECTORY
22+
${CMAKE_BINARY_DIR}/${outdir}
23+
COMMENT
24+
"Generate Doxygen HTML documentation")
25+
message("-- Doxygen HTML index page: "
26+
${CMAKE_BINARY_DIR}/${outdir}/html/index.html)
27+
endfunction()

0 commit comments

Comments
 (0)