diff --git a/build-support/macros-and-definitions.cmake b/build-support/macros-and-definitions.cmake index 37e5621a3..1215c2161 100644 --- a/build-support/macros-and-definitions.cmake +++ b/build-support/macros-and-definitions.cmake @@ -1059,61 +1059,11 @@ macro(process_options) # We checked this already exists, but we need the path to the executable set(DOXYGEN_EXECUTABLE ${DOXYGEN}) - # Get introspected doxygen - add_custom_target( - run-print-introspected-doxygen - COMMAND - ${CMAKE_OUTPUT_DIRECTORY}/utils/ns${NS3_VER}-print-introspected-doxygen${build_profile_suffix} - > ${PROJECT_SOURCE_DIR}/doc/introspected-doxygen.h - COMMAND - ${CMAKE_OUTPUT_DIRECTORY}/utils/ns${NS3_VER}-print-introspected-doxygen${build_profile_suffix} - --output-text > ${PROJECT_SOURCE_DIR}/doc/ns3-object.txt - DEPENDS print-introspected-doxygen - ) - add_custom_target( - run-introspected-command-line - COMMAND ${CMAKE_COMMAND} -E env NS_COMMANDLINE_INTROSPECTION=.. - ${Python3_EXECUTABLE} ./test.py --no-build --constrain=example - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - DEPENDS all-test-targets # all-test-targets only exists if ENABLE_TESTS is - # set to ON - ) - - file( - WRITE ${CMAKE_BINARY_DIR}/introspected-command-line-preamble.h - "/* This file is automatically generated by - CommandLine::PrintDoxygenUsage() from the CommandLine configuration - in various example programs. Do not edit this file! Edit the - CommandLine configuration in those files instead. - */\n" - ) - add_custom_target( - assemble-introspected-command-line - # works on CMake 3.18 or newer > COMMAND ${CMAKE_COMMAND} -E cat - # ${PROJECT_SOURCE_DIR}/testpy-output/*.command-line > - # ${PROJECT_SOURCE_DIR}/doc/introspected-command-line.h - COMMAND - ${cat_command} ${CMAKE_BINARY_DIR}/introspected-command-line-preamble.h - ${PROJECT_SOURCE_DIR}/testpy-output/*.command-line > - ${PROJECT_SOURCE_DIR}/doc/introspected-command-line.h 2> NULL - DEPENDS run-introspected-command-line - ) - add_custom_target( update_doxygen_version COMMAND bash ${PROJECT_SOURCE_DIR}/doc/ns3_html_theme/get_version.sh WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} ) - - add_custom_target( - doxygen - COMMAND ${DOXYGEN_EXECUTABLE} ${PROJECT_SOURCE_DIR}/doc/doxygen.conf - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - DEPENDS update_doxygen_version run-print-introspected-doxygen - assemble-introspected-command-line - USES_TERMINAL - ) - add_custom_target( doxygen-no-build COMMAND ${DOXYGEN_EXECUTABLE} ${PROJECT_SOURCE_DIR}/doc/doxygen.conf @@ -1121,6 +1071,69 @@ macro(process_options) DEPENDS update_doxygen_version USES_TERMINAL ) + # The `doxygen` target only really works if we have tests enabled, so emit a + # warning to use `doxygen-no-build` instead. + if((NOT ${ENABLE_TESTS}) AND (NOT ${ENABLE_EXAMPLES})) + # cmake-format: off + set(doxygen_target_requires_tests_msg + echo The \\'doxygen\\' target called by \\'./ns3 docs doxygen\\' or \\'./ns3 docs all\\' commands + require examples and tests to generate introspected documentation. + Enable examples and tests, or use \\'doxygen-no-build\\'. + ) + # cmake-format: on + add_custom_target(doxygen COMMAND ${doxygen_target_requires_tests_msg}) + unset(doxygen_target_requires_tests_msg) + else() + # Get introspected doxygen + add_custom_target( + run-print-introspected-doxygen + COMMAND + ${CMAKE_OUTPUT_DIRECTORY}/utils/ns${NS3_VER}-print-introspected-doxygen${build_profile_suffix} + > ${PROJECT_SOURCE_DIR}/doc/introspected-doxygen.h + COMMAND + ${CMAKE_OUTPUT_DIRECTORY}/utils/ns${NS3_VER}-print-introspected-doxygen${build_profile_suffix} + --output-text > ${PROJECT_SOURCE_DIR}/doc/ns3-object.txt + DEPENDS print-introspected-doxygen + ) + add_custom_target( + run-introspected-command-line + COMMAND ${CMAKE_COMMAND} -E env NS_COMMANDLINE_INTROSPECTION=.. + ${Python3_EXECUTABLE} ./test.py --no-build --constrain=example + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + DEPENDS all-test-targets # all-test-targets only exists if ENABLE_TESTS + # is set to ON + ) + + file( + WRITE ${CMAKE_BINARY_DIR}/introspected-command-line-preamble.h + "/* This file is automatically generated by + CommandLine::PrintDoxygenUsage() from the CommandLine configuration + in various example programs. Do not edit this file! Edit the + CommandLine configuration in those files instead. + */\n" + ) + add_custom_target( + assemble-introspected-command-line + # works on CMake 3.18 or newer > COMMAND ${CMAKE_COMMAND} -E cat + # ${PROJECT_SOURCE_DIR}/testpy-output/*.command-line > + # ${PROJECT_SOURCE_DIR}/doc/introspected-command-line.h + COMMAND + ${cat_command} + ${CMAKE_BINARY_DIR}/introspected-command-line-preamble.h + ${PROJECT_SOURCE_DIR}/testpy-output/*.command-line > + ${PROJECT_SOURCE_DIR}/doc/introspected-command-line.h 2> NULL + DEPENDS run-introspected-command-line + ) + + add_custom_target( + doxygen + COMMAND ${DOXYGEN_EXECUTABLE} ${PROJECT_SOURCE_DIR}/doc/doxygen.conf + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + DEPENDS update_doxygen_version run-print-introspected-doxygen + assemble-introspected-command-line + USES_TERMINAL + ) + endif() endif() # Now we check for sphinx dependencies diff --git a/ns3 b/ns3 index deb047ff2..4bd72a653 100755 --- a/ns3 +++ b/ns3 @@ -1457,7 +1457,7 @@ def main(): args.build = [args.docs] if args.docs != "all" else ["sphinx", "doxygen"] if "doxygen" in args.build and (not build_info["ENABLE_EXAMPLES"] or not build_info["ENABLE_TESTS"]): print('The "./ns3 docs doxygen" and "./ns3 docs all" commands,\n' - 'require examples and tests to generate introspected documentation.\n' + 'requires examples and tests to generate introspected documentation.\n' 'Try "./ns3 docs doxygen-no-build" or enable examples and tests.') exit(1)