COMP: Detect the VTK rendering backend from imported targets - #6850
Merged
hjmjohnson merged 1 commit intoSep 7, 2026
Merged
Conversation
hjmjohnson
marked this pull request as ready for review
September 6, 2026 17:04
hjmjohnson
marked this pull request as draft
September 6, 2026 17:07
Contributor
|
VTK 9 does not define VTK_RENDERING_BACKEND, so the fallback to OpenGL2 always fired and every "STREQUAL None" guard was unconditionally true. ITKVtkGlue therefore required a rendering-enabled VTK even though its sources and tests already guard the viewer classes for the None case. The same block appears in the two export-code strings, which run at the consumer's find_package(ITK), so a downstream project re-ran the broken detection as well. All three are changed.
hjmjohnson
force-pushed
the
comp-vtkglue-rendering-detection
branch
from
September 6, 2026 17:30
9ea5e23 to
b1f8fc7
Compare
hjmjohnson
marked this pull request as ready for review
September 6, 2026 17:31
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #6846.
ITKVtkGluecannot configure against a VTK built without rendering, even though the module contains explicit logic intended to support that case. The logic is unreachable because it testsVTK_RENDERING_BACKEND, a VTK 8 variable that VTK 9 does not define.Detect the backend from the imported targets instead, so the existing
STREQUAL "None"guards work as written.Why the existing guards never fire
itk-module-init.cmakedefaults the backend when the variable is empty:VTK 9 never sets
VTK_RENDERING_BACKEND— confirmed against a 9.6.2 install:So the variable is always empty, always becomes
OpenGL2, and everyif(NOT VTK_RENDERING_BACKEND STREQUAL "None")guard is unconditionally true.The rendering libraries are appended in all cases, and
vtk_module_autoinitis then called withVTK::RenderingOpenGL2on a VTK thatmay not have it.
The module was written to support a rendering-free VTK:
src/CMakeLists.txtalready guards
QuickView.cxx, andtest/CMakeLists.txtalready guards theviewer tests, both on the same
STREQUAL "None"condition. Only the line thatcomputes the value is wrong, so an intended-optional dependency has been
mandatory for the whole VTK 9 era.
Four sites
The detection block appears three times, and two of those run at the
consumer's
find_package(ITK)rather than in ITK's own configure:itk-module-init.cmakeCMakeLists.txt,ITKVtkGlue_EXPORT_CODE_INSTALLfind_package(ITK)CMakeLists.txt,ITKVtkGlue_EXPORT_CODE_BUILDfind_package(ITK)So the effect is not limited to building ITK — every downstream project that
consumes an installed ITK re-runs the same broken detection.
A fourth site is in the wrapping layer and contains no reference to the
variable at all.
itk_auto_load_and_end_wrap_submodules()discovers every.wrapfile, soitkViewImagewas wrapped regardless of the backend, anditkViewImage.hxxincludesvtkRenderWindow.h. With the three CMake sitesfixed, configure succeeded and the build then failed:
wrapping/itkViewImage.wrapnow carries the sameSTREQUAL "None"guard thesources and tests already use.
The two export-code copies live inside quoted strings whose escaping is
documented at
CMakeLists.txt:70:\${VTK_RENDERING_BACKEND}must stayescaped so it expands at consumer time, and the comment warns that mixing
escaped and unescaped forms is a latent bug (see PR #6144). The replacement
introduces no new variable references — only an
if(TARGET ...)test — so itdoes not interact with that hazard.
Verification
macOS arm64, two purpose-built VTK 9.6.2 trees differing only in rendering.
With rendering (
VTK_GROUP_ENABLE_Rendering=WANT) — no regression:Without rendering (
VTK_GROUP_ENABLE_Rendering=NO) — the case thatpreviously could not configure at all:
configure now succeeds; on
mainit fails withthe build completes, 0 errors
8 tests register and 8/8 pass: the three non-rendering C++ tests, the
three Python tests and the two style checks
the three viewer tests (
itkVtkMedianImageFilterTest,QuickViewTest,itkVtkConnectedComponentImageFilterTest) are correctly excludedNote for reviewers merging alongside #6848
#6848 also touches
Modules/Bridge/VtkGlue/itk-module-init.cmake, addingconfigure-time checks for unusable VTK configurations. The two changes are in
different regions of the file and are logically independent, but a textual
conflict is possible depending on merge order. Happy to rebase whichever lands
second.