diff --git a/CMakeLists.txt b/CMakeLists.txt index b485488b3..5070e3aa5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 "") @@ -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) @@ -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) diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt new file mode 100644 index 000000000..7aa89edeb --- /dev/null +++ b/docs/CMakeLists.txt @@ -0,0 +1 @@ +EnableDoxygen(docs) diff --git a/docs/Doxyfile.in b/docs/Doxyfile.in index 23349c8da..93a26c5a2 100644 --- a/docs/Doxyfile.in +++ b/docs/Doxyfile.in @@ -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 @@ -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 @@ -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. diff --git a/docs/cmake/EnableDoxygen.cmake b/docs/cmake/EnableDoxygen.cmake new file mode 100644 index 000000000..20af91e59 --- /dev/null +++ b/docs/cmake/EnableDoxygen.cmake @@ -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()