From 10b1e7c6bbabe1cf3a6f0356745c2b9eb828a64f Mon Sep 17 00:00:00 2001 From: "Hans J. Johnson" Date: Sun, 6 Sep 2026 10:24:58 -0500 Subject: [PATCH 1/2] COMP: Reject unusable VTK configurations at configure time A VTK without Python wrapping, or a static VTK whose wrapping collapses into a single _vtkmodules_static module, is only detected when the Python tests run and fail to import. Check both while configuring and name the remedy. VTK exports no shared/static variable, so the imported VTK::CommonCore target is queried directly. --- Modules/Bridge/VtkGlue/itk-module-init.cmake | 27 ++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/Modules/Bridge/VtkGlue/itk-module-init.cmake b/Modules/Bridge/VtkGlue/itk-module-init.cmake index 550f1dce272..acd973ccefb 100644 --- a/Modules/Bridge/VtkGlue/itk-module-init.cmake +++ b/Modules/Bridge/VtkGlue/itk-module-init.cmake @@ -54,4 +54,31 @@ if(NOT VTK_RENDERING_BACKEND STREQUAL "None") ) endif() +if(ITK_WRAP_PYTHON) + if(NOT VTK_WRAP_PYTHON) + message( + FATAL_ERROR + "ITK_WRAP_PYTHON is ON and Module_ITKVtkGlue is enabled, but the VTK at\n" + " ${VTK_DIR}\n" + "was built with VTK_WRAP_PYTHON=OFF. Rebuild VTK with VTK_WRAP_PYTHON=ON,\n" + "or set Module_ITKVtkGlue=OFF." + ) + endif() + # VTK exports no shared/static variable, so ask an imported target directly. + if(TARGET VTK::CommonCore) + get_target_property(_vtk_common_core_type VTK::CommonCore TYPE) + if(_vtk_common_core_type STREQUAL "STATIC_LIBRARY") + message( + FATAL_ERROR + "ITK_WRAP_PYTHON is ON and Module_ITKVtkGlue is enabled, but the VTK at\n" + " ${VTK_DIR}\n" + "is a static build. Its Python wrapping collapses into a single\n" + "_vtkmodules_static module that ITK's wrapping cannot import. Rebuild VTK\n" + "with BUILD_SHARED_LIBS=ON, or set Module_ITKVtkGlue=OFF." + ) + endif() + unset(_vtk_common_core_type) + endif() +endif() + set(ITKVtkGlue_VTK_LIBRARIES ${_required_vtk_libraries}) From 29dd4df4d938845b2ce29e1105f9bb72f5b87d33 Mon Sep 17 00:00:00 2001 From: "Hans J. Johnson" Date: Sun, 6 Sep 2026 10:25:45 -0500 Subject: [PATCH 2/2] COMP: Put VTK's DLL directory on PATH for the VtkGlue tests on Windows Windows has no RPATH, so the test executables abort with STATUS_DLL_NOT_FOUND before reaching main, which ctest reports only as an opaque exit code. The Python tests are unaffected because itkTestDriver already sets their environment. ENVIRONMENT_MODIFICATION is a no-op on other platforms. --- Modules/Bridge/VtkGlue/test/CMakeLists.txt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Modules/Bridge/VtkGlue/test/CMakeLists.txt b/Modules/Bridge/VtkGlue/test/CMakeLists.txt index 8310ce7ff66..8856e2b5c15 100644 --- a/Modules/Bridge/VtkGlue/test/CMakeLists.txt +++ b/Modules/Bridge/VtkGlue/test/CMakeLists.txt @@ -110,3 +110,19 @@ if(NOT VTK_RENDERING_BACKEND STREQUAL "None") REQUIRES_DISPLAY ) endif() + +# Windows has no RPATH, so VTK's DLLs must be on PATH at test time. +if(WIN32 AND TARGET VTK::CommonCore) + get_property(_vtkglue_tests DIRECTORY PROPERTY TESTS) + if(_vtkglue_tests) + set_property( + TEST + ${_vtkglue_tests} + APPEND + PROPERTY + ENVIRONMENT_MODIFICATION + "PATH=path_list_prepend:$" + ) + endif() + unset(_vtkglue_tests) +endif()