Problem with Building ITK with Module_ItkVtkGlue = ON

Hi All,

I got a problem when building ITK in release (version 5.10 in github: https://github.com/InsightSoftwareConsortium/ITK) with setting Module_ItkVtkGlue = ON. Actually I set VTK_DIR points to the my latest installed VTK release at: /usr/local/lib/cmake/vtk-8.90/. But when I compile the ITK source, the compiler thew an error:

In file included from /home/phongtd/workingspace/ITK/build/Wrapping/itkImageToVTKImageFilter.cxx:16:
/home/phongtd/workingspace/ITK/Modules/Bridge/VtkGlue/include/itkImageToVTKImageFilter.h:22:10: fatal error: 'vtkImageImport.h' file not found
#include "vtkImageImport.h"
         ^~~~~~~~~~~~~~~~~~
1 error generated.
Wrapping/Modules/ITKVtkGlue/CMakeFiles/ITKVtkGlueCastXML.dir/build.make:64: recipe for target 'Wrapping/itkImageToVTKImageFilter.xml' failed
make[2]: *** [Wrapping/itkImageToVTKImageFilter.xml] Error 1
make[2]: *** Waiting for unfinished jobs....
[ 29%] Generating ../../../itkPyCommand.xml
In file included from /home/phongtd/workingspace/ITK/build/Wrapping/itkVTKImageToImageFilter.cxx:16:
/home/phongtd/workingspace/ITK/Modules/Bridge/VtkGlue/include/itkVTKImageToImageFilter.h:23:10: fatal error: 'vtkImageExport.h' file not found
#include "vtkImageExport.h"
         ^~~~~~~~~~~~~~~~~~
1 error generated.
Wrapping/Modules/ITKVtkGlue/CMakeFiles/ITKVtkGlueCastXML.dir/build.make:70: recipe for target 'Wrapping/itkVTKImageToImageFilter.xml' failed
make[2]: *** [Wrapping/itkVTKImageToImageFilter.xml] Error 1
CMakeFiles/Makefile2:51906: recipe for target 'Wrapping/Modules/ITKVtkGlue/CMakeFiles/ITKVtkGlueCastXML.dir/all' failed
make[1]: *** [Wrapping/Modules/ITKVtkGlue/CMakeFiles/ITKVtkGlueCastXML.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 29%] Generating ../../../itkPyImageFilter.xml
[ 29%] Built target ITKPyUtilsCastXML
Makefile:162: recipe for target 'all' failed
make: *** [all] Error 2

I although I cann see that file in : /usr/local/include/vtk-8.90/vtkImageImport.h. I guess ITK CMakeLists.txt did not include $VTK_INCLUDE_DIRS.

I tried to search on google and found the similar link: http://itk-users.7.n7.nabble.com/Problem-with-Building-ITK-with-Module-ItkVtkGlue-ON-td30777.html. But that was not a complete answer. Can anyone help me on this ?

I am getting the same error and see that some of the include flags are not included.

Including the VTK include directory in /ITKVtkGlue.castxml.inc seems to make progress. Now to find where this file is generated from.

This segment shows that the include directories are set only if the VTK version is 6.0.0 or less:
if( ${VTK_VERSION} VERSION_LESS 6.0.0 )
set(ITKVtkGlue_VTK_INCLUDE_DIRS ${VTK_INCLUDE_DIRS})
set(ITKVtkGlue_VTK_LIBRARIES ${VTK_LIBRARIES})