Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions Utilities/Doxygen/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -162,31 +162,43 @@ if(ITK_BUILD_DOCUMENTATION)

find_package(LATEX)

file(
GLOB_RECURSE EXAMPLES_LIST
CONFIGURE_DEPENDS
"${ITK_SOURCE_DIR}/Examples/*.cxx"
"${ITK_SOURCE_DIR}/Examples/*.py"
"${ITK_SOURCE_DIR}/Examples/*.java"
Comment thread
hjmjohnson marked this conversation as resolved.
)
set(ITK_EXAMPLES ${ITK_BINARY_DIR}/Documentation/Doxygen/Examples.dox)

# Custom command to generate a examples page which include all ITK examples
add_custom_command(
OUTPUT
"${ITK_BINARY_DIR}/Documentation/Doxygen/Examples.dox"
Examples.dox
COMMAND
${CMAKE_COMMAND} -D "PROJECT_SOURCE_DIR:PATH=${ITK_SOURCE_DIR}" -D
"OUTPUT_FILE:PATH=${ITK_BINARY_DIR}/Documentation/Doxygen/Examples.dox" -P
"OUTPUT_FILE:PATH=${ITK_EXAMPLES}" -P
"${ITK_SOURCE_DIR}/Utilities/Doxygen/GenerateExamplesDox.cmake"
WORKING_DIRECTORY "${ITK_SOURCE_DIR}/Examples"
#WORKING_DIRECTORY "${ITK_SOURCE_DIR}/Examples"
WORKING_DIRECTORY ${ITK_BINARY_DIR}/Documentation/Doxygen
DEPENDS
"${ITK_SOURCE_DIR}/Examples"
${EXAMPLES_LIST}
"${ITK_SOURCE_DIR}/Utilities/Doxygen/GenerateExamplesDox.cmake"
)
add_custom_target(
ITKDoxygenExamplesDox
DEPENDS
"${ITK_BINARY_DIR}/Documentation/Doxygen/Examples.dox"
set_source_files_properties(
${ITK_EXAMPLES}
PROPERTIES
GENERATED
1
)
Comment on lines 175 to 193

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Match generated output
OUTPUT Examples.dox and the target dependency are relative to this CMake directory’s binary tree, but the script writes to ${ITK_EXAMPLES} under Documentation/Doxygen. With Ninja/Make, the declared output is never produced, so the custom command remains out of date or fails after generation even though the intended file exists.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@albert-github Can you please address this greptile concern?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will look into it, but it will take a bit over a week before I have time to really look into it (and I don't have ninja).

@hjmjohnson hjmjohnson Jul 8, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@albert-github

Greptile is right, and I confirmed with a minimal Ninja reproduction that this fails on a fresh build tree. Two problems:

  1. A relative OUTPUT Examples.dox resolves to ${ITK_BINARY_DIR}/Utilities/Doxygen/Examples.dox (this directory's binary dir), while the script writes to ${ITK_EXAMPLES} under Documentation/Doxygen — so the declared output is never produced.
  2. Ninja does not create WORKING_DIRECTORY, so cd .../Documentation/Doxygen fails before the script even runs. Since GenerateExamplesDox.cmake uses only absolute paths, the WORKING_DIRECTORY can be dropped entirely.

Suggested replacement (verified to build and be a no-op on rebuild with Ninja):

add_custom_command(
  OUTPUT
    ${ITK_EXAMPLES}
  COMMAND
    ${CMAKE_COMMAND} -D "PROJECT_SOURCE_DIR:PATH=${ITK_SOURCE_DIR}" -D
    "OUTPUT_FILE:PATH=${ITK_EXAMPLES}" -P
    "${ITK_SOURCE_DIR}/Utilities/Doxygen/GenerateExamplesDox.cmake"
  DEPENDS
    ${EXAMPLES_LIST}
    "${ITK_SOURCE_DIR}/Utilities/Doxygen/GenerateExamplesDox.cmake"
)
add_custom_target(ITKDoxygenExamplesDox ALL DEPENDS ${ITK_EXAMPLES})

The set_source_files_properties(... GENERATED 1) block can also be removed — add_custom_command outputs are automatically marked GENERATED — and please delete the commented-out #WORKING_DIRECTORY line rather than keeping it.

add_custom_target(ITKDoxygenExamplesDox ALL DEPENDS Examples.dox)

set(
ITK_DOXYGEN_INPUT
${DOXYGEN_INCLUDE_DIRS}
${ITK_SOURCE_DIR}/Documentation/Doxygen
${ITK_BINARY_DIR}/Documentation/Doxygen
${ITK_BINARY_DIR}/Documentation/Doxygen/Examples.dox
${ITK_EXAMPLES}
${ITK_BINARY_DIR}/Utilities/Doxygen/Modules
${ITK_DOXYGEN_INPUT}
)
Expand Down
Loading