Trouble building ITK python wrapping

I want to include ITK python wrapping in my Slicer build, but building fails when I turn on Slicer_BUILD_ITKPython, with the following error in the make output

...
-- ITKPyUtils: Creating itkPyCommand submodule.
-- ITKPyUtils: Creating itkPyImageFilter submodule.
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
_vtk_lib_include_dirs
   used as include directory in directory /home/ebrahim/Slicer-SuperBuild-Debug/ITK/Modules/Bridge/VtkGlue/wrapping
   used as include directory in directory /home/ebrahim/Slicer-SuperBuild-Debug/ITK/Modules/Bridge/VtkGlue/wrapping
  ... <more of the same message>
   used as include directory in directory /home/ebrahim/Slicer-SuperBuild-Debug/ITK/Modules/Bridge/VtkGlue/wrapping
-- Configuring incomplete, errors occurred!

I see the variable _vtk_lib_include_dirs getting assigned here in ITK, but I don’t really know what’s going on. Not sure if this is a Slicer issue or an ITK issue. Any ideas?

Slicer passes VTK_DIR to ITK here, which should be sufficient for ITK to configure ITKVTKGlue.

@thewtex do you have any idea what can go wrong?

1 Like

Thanks for the report. I will have a look and report back shortly.

2 Likes

I would recommend updating to ITK v5.3rc03. VTK changes its CMake configuration often. There have been updates.

1 Like

Here is work already in progress to use most recent ITK. This branch could be used for testing the ITK python wrapping

1 Like

Note this previous attempt linked below of me trying to build ITK python. Some discussion was about pip install itk as an easier option for Slicer instead of changing Slicer to build ITK python wrapping as part of the nightly build process.

A post was split to a new topic: Addressing issue with “pip install itk”

Thanks for pointing me to this PR!
I will try building off this branch and report back.

1 Like

With that branch I ended up with the following error during build on linux:

[100%] Generating ../../itkImageToVTKImageFilter.xml
In file included from /path/to/superbuild/ITK-build/Wrapping/itkImageToVTKImageFilter.cxx:16:
/path/to/superbuild/ITK/Modules/Bridge/VtkGlue/include/itkImageToVTKImageFilter.h:22:10: fatal error: 'vtkImageImport.h' file not found
#include "vtkImageImport.h"
         ^~~~~~~~~~~~~~~~~~
1 error generated.
make[5]: *** [Wrapping/Modules/ITKVtkGlue/CMakeFiles/ITKVtkGlueCastXML.dir/build.make:65: Wrapping/itkImageToVTKImageFilter.xml] Error 1
make[4]: *** [CMakeFiles/Makefile2:36492: Wrapping/Modules/ITKVtkGlue/CMakeFiles/ITKVtkGlueCastXML.dir/all] Error 2
make[3]: *** [Makefile:152: all] Error 2
make[2]: *** [slicersources-build/CMakeFiles/ITK.dir/build.make:118: slicersources-build/ITK-prefix/src/ITK-stamp/ITK-build] Error 2
make[1]: *** [CMakeFiles/Makefile2:877: slicersources-build/CMakeFiles/ITK.dir/all] Error 2
make: *** [Makefile:84: all] Error 2

EDIT: I should add that I was trying this with a Slicer Custom App, not with vanilla Slicer. So the issue may be related to the way in which I included the new branch. Perhaps I omitted a needed change in my top level cmake file.

I’ll continue digging into this.

Update: Same error with vanilla Slicer.