50 lines
1.9 KiB
CMake
50 lines
1.9 KiB
CMake
|
|
# Run doxygen with PROJECT_NUMBER supplied from CMake, and fail on any warning.
|
||
|
|
#
|
||
|
|
# Driven by the `docs` target in the top-level CMakeLists.txt. It is a separate
|
||
|
|
# script rather than a COMMAND because it has to do three things in sequence --
|
||
|
|
# feed the configuration in, then read the log back, then decide -- and a
|
||
|
|
# custom-target command list cannot branch on the result of an earlier command.
|
||
|
|
#
|
||
|
|
# The version comes in from CMake rather than living in the Doxyfile so that
|
||
|
|
# project() stays the single place a version number is written.
|
||
|
|
|
||
|
|
if(NOT AKSL_DOXYGEN OR NOT AKSL_SOURCE_DIR OR NOT AKSL_VERSION)
|
||
|
|
message(FATAL_ERROR "RunDoxygen.cmake needs AKSL_DOXYGEN, AKSL_SOURCE_DIR and AKSL_VERSION")
|
||
|
|
endif()
|
||
|
|
|
||
|
|
set(_doxyfile "${AKSL_SOURCE_DIR}/Doxyfile")
|
||
|
|
set(_logfile "${AKSL_SOURCE_DIR}/doxygen-warnings.log")
|
||
|
|
file(READ "${_doxyfile}" _config)
|
||
|
|
# Later settings win in a Doxyfile, so appending is enough to override.
|
||
|
|
set(_config "${_config}\nPROJECT_NUMBER = ${AKSL_VERSION}\n")
|
||
|
|
|
||
|
|
set(_generated "${AKSL_SOURCE_DIR}/Doxyfile.generated")
|
||
|
|
file(WRITE "${_generated}" "${_config}")
|
||
|
|
|
||
|
|
execute_process(
|
||
|
|
COMMAND "${AKSL_DOXYGEN}" "${_generated}"
|
||
|
|
WORKING_DIRECTORY "${AKSL_SOURCE_DIR}"
|
||
|
|
RESULT_VARIABLE _result
|
||
|
|
OUTPUT_QUIET
|
||
|
|
)
|
||
|
|
file(REMOVE "${_generated}")
|
||
|
|
|
||
|
|
if(NOT _result EQUAL 0)
|
||
|
|
message(FATAL_ERROR "doxygen exited ${_result}")
|
||
|
|
endif()
|
||
|
|
|
||
|
|
# WARN_IF_UNDOCUMENTED and WARN_NO_PARAMDOC are on, so anything in the log is a
|
||
|
|
# public function, parameter or return value nobody has described. Treat it the
|
||
|
|
# way an uncovered line or a surviving mutant is treated: as work, not as noise.
|
||
|
|
if(EXISTS "${_logfile}")
|
||
|
|
file(READ "${_logfile}" _warnings)
|
||
|
|
string(STRIP "${_warnings}" _warnings)
|
||
|
|
if(NOT _warnings STREQUAL "")
|
||
|
|
message("${_warnings}")
|
||
|
|
message(FATAL_ERROR
|
||
|
|
"doxygen reported undocumented entities; see doxygen-warnings.log")
|
||
|
|
endif()
|
||
|
|
endif()
|
||
|
|
|
||
|
|
message(STATUS "API documentation written to ${AKSL_SOURCE_DIR}/doxygen/html")
|