Skip to content

Commit

Permalink
Enable doxygen documentation in the cmake build system (#1281)
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewMasarik-NOAA authored Aug 1, 2024
1 parent b4e119e commit abc77b9
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 5 deletions.
12 changes: 10 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ project(

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

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

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

add_subdirectory(model)

# Turn on doxygen documentation
if (ENABLE_DOCS)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/docs/cmake")
include(EnableDoxygen)
add_subdirectory(docs)
endif()

# Turn on unit testing.
#include(CTest)
#if(BUILD_TESTING)
Expand Down
1 change: 1 addition & 0 deletions docs/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
EnableDoxygen(docs)
6 changes: 3 additions & 3 deletions docs/Doxyfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ PROJECT_LOGO =
# entered, it will be relative to the location where doxygen was started. If
# left blank the current directory will be used.

OUTPUT_DIRECTORY = docs
OUTPUT_DIRECTORY = @doc_output@

# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub-
# directories (in 2 levels) under the output directory of each output format and
Expand Down Expand Up @@ -829,7 +829,7 @@ WARN_LOGFILE =
# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
# Note: If this tag is empty the current directory is searched.

INPUT = model/src
INPUT = @src_input@

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

DIA_PATH =
DIA_PATH =

# If set to YES the inheritance and collaboration graphs will hide inheritance
# and usage relations if the target is undocumented or is not a class.
Expand Down
27 changes: 27 additions & 0 deletions docs/cmake/EnableDoxygen.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Doxygen documentation- Matt Masarik 24-Jul-2024.
function(EnableDoxygen outdir)
find_package(Doxygen REQUIRED)
if (NOT DOXYGEN_FOUND)
add_custom_target(enable_docs
COMMAND false
COMMENT "Doxygen not found")
return()
endif()

set(src_input "${CMAKE_SOURCE_DIR}/model/src")
set(doc_output "${CMAKE_BINARY_DIR}/${outdir}")
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/${outdir}/html)
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/docs/Doxyfile.in
${CMAKE_BINARY_DIR}/${outdir}/Doxyfile @ONLY)
set(DOXYGEN_GENERATE_HTML YES)
set(DOXYGEN_QUIET YES)
add_custom_target(enable_docs
COMMAND
${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/${outdir}/Doxyfile
WORKING_DIRECTORY
${CMAKE_BINARY_DIR}/${outdir}
COMMENT
"Generate Doxygen HTML documentation")
message("-- Doxygen HTML index page: "
${CMAKE_BINARY_DIR}/${outdir}/html/index.html)
endfunction()

0 comments on commit abc77b9

Please sign in to comment.