From 9f92d17bbb566c46553d14842d2a4d8967535815 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C5=BEenan=20Zuki=C4=87?= Date: Wed, 21 Oct 2026 17:05:05 -0400 Subject: [PATCH] COMP: Report a VTK/ITK Python mismatch clearly in ITKVtkGlue A Python-wrapped VTK's config fills Python3_INCLUDE_DIR and Python3_LIBRARY from its build but keeps an already selected Python3_EXECUTABLE. When the two Pythons differ, FindPython3 failed inside VTK's config with a misleading missing Development.Module error. Find VTK without REQUIRED and report the selected interpreter and VTK's Python paths instead. --- Modules/Bridge/VtkGlue/itk-module-init.cmake | 22 +++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/Modules/Bridge/VtkGlue/itk-module-init.cmake b/Modules/Bridge/VtkGlue/itk-module-init.cmake index fa61a05e02a..7d855eb0ac4 100644 --- a/Modules/Bridge/VtkGlue/itk-module-init.cmake +++ b/Modules/Bridge/VtkGlue/itk-module-init.cmake @@ -14,7 +14,27 @@ # but not required. set(VERSION_MIN "9.1.0") -find_package(VTK ${VERSION_MIN} NO_MODULE REQUIRED) +find_package(VTK ${VERSION_MIN} NO_MODULE) +if(NOT VTK_FOUND) + message( + FATAL_ERROR + "Module_ITKVtkGlue requires VTK >= ${VERSION_MIN}. Set VTK_DIR to its CMake package directory.\n" + "${VTK_NOT_FOUND_MESSAGE}" + ) +endif() +# Not REQUIRED, so a Python-wrapped VTK reports an unusable Python here instead of failing inside FindPython3. +if(VTK_WRAP_PYTHON AND DEFINED VTK_Python_FOUND AND NOT VTK_Python_FOUND) + message( + FATAL_ERROR + "The VTK at\n" + " ${VTK_DIR}\n" + "is Python-wrapped, but its Python is inconsistent with the selected one:\n" + " Python3_EXECUTABLE=${Python3_EXECUTABLE} (Python ${Python3_VERSION})\n" + " Python3_INCLUDE_DIR=${Python3_INCLUDE_DIR}\n" + " Python3_LIBRARY=${Python3_LIBRARY}\n" + "Set Python3_EXECUTABLE to the Python VTK was built with, or set Module_ITKVtkGlue=OFF." + ) +endif() # VTK 9 omits VTK_RENDERING_BACKEND; infer rendering support from its OpenGL2 target. if(NOT VTK_RENDERING_BACKEND)