Summary
ITKVtkGlue cannot be configured against a VTK built without rendering, even though the module contains explicit logic intended to support exactly that. The logic is unreachable because it tests VTK_RENDERING_BACKEND, a VTK 8 variable that VTK 9 does not define.
The dead branch
Modules/Bridge/VtkGlue/itk-module-init.cmake:19
if(NOT VTK_RENDERING_BACKEND)
set(VTK_RENDERING_BACKEND OpenGL2)
endif()
Modules/Bridge/VtkGlue/itk-module-init.cmake:44
if(NOT VTK_RENDERING_BACKEND STREQUAL "None")
list(APPEND _required_vtk_libraries
VTK::Rendering${VTK_RENDERING_BACKEND}
VTK::RenderingFreeType
${_target_freetypeopengl}
VTK::InteractionStyle
VTK::InteractionWidgets)
endif()
VTK 9 does not set VTK_RENDERING_BACKEND. Confirmed against a 9.6.2 install:
$ grep -rl VTK_RENDERING_BACKEND <vtk-build>/lib/cmake/vtk-9.6/
(no matches)
So the variable is always empty, always becomes OpenGL2, and the STREQUAL "None" guard can never be false. The rendering libraries are appended unconditionally.
The same variable gates the optional C++ tests in Modules/Bridge/VtkGlue/test/CMakeLists.txt:8, so itkVtkMedianFilterTest, itkVtkConnectedComponentImageFilterTest and QuickViewTest are likewise always enabled.
This appears to have been inert since ITK began requiring VTK 9. The file's own comment states the minimum is VTK 9.1.
Reproduction
Build VTK with rendering disabled and Python wrapping on:
cmake -S VTK -B vtk-build -GNinja \
-DVTK_ENABLE_KITS=OFF -DVTK_WRAP_PYTHON=ON \
-DVTK_GROUP_ENABLE_Rendering=NO -DVTK_GROUP_ENABLE_Qt=NO
cmake --build vtk-build
Then configure ITK against it:
cmake -S ITK -B itk-build -GNinja \
-DBUILD_TESTING=ON -DModule_ITKVtkGlue=ON -DVTK_DIR=<vtk-build>
Result:
CMake Error at <vtk-build>/lib/cmake/vtk-9.6/vtkModule.cmake:1348 (message):
Failed to determine the real target for the `VTK::RenderingOpenGL2` module.
The module name is not a CMake target. Is there a typo? Is it missing a
`Package::` prefix? Is a `find_package` missing a required component?
Call Stack (most recent call first):
<vtk-build>/lib/cmake/vtk-9.6/vtkModule.cmake:3430 (_vtk_module_real_target)
Modules/Bridge/VtkGlue/test/CMakeLists.txt:26 (vtk_module_autoinit)
The message points at vtk_module_autoinit and names a VTK-internal function, which does not suggest the actual cause.
Why this matters
Headless VTK builds are ordinary in CI containers, HPC nodes and server-side pipelines. The image-conversion half of ITKVtkGlue — itk::ImageToVTKImageFilter and itk::VTKImageToImageFilter — needs no rendering at all, and three of the module's C++ tests (itkImageToVTKImageFilterTest, itkImageToVTKImageFilterRGBTest, itkVTKImageToImageFilterTest) exercise only that path. Today none of them can be built without dragging in OpenGL, FreeType and the interaction modules.
Suggested fix
Detect the backend from imported targets rather than the removed variable:
if(TARGET VTK::RenderingOpenGL2)
set(VTK_RENDERING_BACKEND OpenGL2)
else()
set(VTK_RENDERING_BACKEND None)
endif()
Both existing STREQUAL "None" guards then work as written; no other changes appear necessary. _target_freetypeopengl already uses the if(TARGET ...) idiom immediately below, so this is consistent with the surrounding code.
Behaviour is unchanged for anyone whose VTK has rendering. Anyone whose VTK lacks it moves from a hard configure error to a working ITKVtkGlue without the view-related classes and tests.
I am happy to prepare the patch. It should follow #6715 (ITKVtkGlue wrapping), which is in review and touches the same module.
Summary
ITKVtkGluecannot be configured against a VTK built without rendering, even though the module contains explicit logic intended to support exactly that. The logic is unreachable because it testsVTK_RENDERING_BACKEND, a VTK 8 variable that VTK 9 does not define.The dead branch
Modules/Bridge/VtkGlue/itk-module-init.cmake:19Modules/Bridge/VtkGlue/itk-module-init.cmake:44VTK 9 does not set
VTK_RENDERING_BACKEND. Confirmed against a 9.6.2 install:So the variable is always empty, always becomes
OpenGL2, and theSTREQUAL "None"guard can never be false. The rendering libraries are appended unconditionally.The same variable gates the optional C++ tests in
Modules/Bridge/VtkGlue/test/CMakeLists.txt:8, soitkVtkMedianFilterTest,itkVtkConnectedComponentImageFilterTestandQuickViewTestare likewise always enabled.This appears to have been inert since ITK began requiring VTK 9. The file's own comment states the minimum is VTK 9.1.
Reproduction
Build VTK with rendering disabled and Python wrapping on:
Then configure ITK against it:
Result:
The message points at
vtk_module_autoinitand names a VTK-internal function, which does not suggest the actual cause.Why this matters
Headless VTK builds are ordinary in CI containers, HPC nodes and server-side pipelines. The image-conversion half of ITKVtkGlue —
itk::ImageToVTKImageFilteranditk::VTKImageToImageFilter— needs no rendering at all, and three of the module's C++ tests (itkImageToVTKImageFilterTest,itkImageToVTKImageFilterRGBTest,itkVTKImageToImageFilterTest) exercise only that path. Today none of them can be built without dragging in OpenGL, FreeType and the interaction modules.Suggested fix
Detect the backend from imported targets rather than the removed variable:
Both existing
STREQUAL "None"guards then work as written; no other changes appear necessary._target_freetypeopenglalready uses theif(TARGET ...)idiom immediately below, so this is consistent with the surrounding code.Behaviour is unchanged for anyone whose VTK has rendering. Anyone whose VTK lacks it moves from a hard configure error to a working ITKVtkGlue without the view-related classes and tests.
I am happy to prepare the patch. It should follow #6715 (ITKVtkGlue wrapping), which is in review and touches the same module.