Which of path should set to ITK_DIR

Hello, I just build ITK with cmake. Now I have two folder, ITK_source and ITK_build. I set my ITK_DIR to ITK_build but get no head file error. And I found that some ITK module just have .obj file and no .cxx or .h. In ITK_source folder I have head file.
So could someone tell me how to set ITK_DIR, or is there some mistake in my cmake building?

The ITKConfig.cmake file in your ITK_build folder automatically includes the headers from your ITK_source folder.

There must some kind of mistake in your building, did it compile without errors?. For sanity, I would recommend a fresh start, delete ITK_build and start over.

It is normal that source files (.h, .hxx and .cxx) are in source folder, and compiled files (.obj, .lib, .dll and .exe) in the build folder. When you need to provide ITK_DIR to your own project, use ITK_build.

Thanks for reply. I got this error because I do not set CMAKE_INSTALL_PREFIX to ITK_source.
But now I got new error for itkVTKImageToImageFilter.h not found but other .h work well.
I add ITKGroup_Bridge in cmake.
image

This is my cmakelist:

  • set (ITK_DIR “D:\C_package\ITK_build”)
  • find_package(ITK CONFIG REQUIRED)
  • include("${ITK_USE_FILE}")
  • target_link_libraries(Reconstruction ${ITK_LIBRARIES})

Great that you are making progress.

CMAKE_INSTALL_PREFIX to ITK_source

That’s wasn’t the source of the error. CMAKE_INSTALL_PREFIX only plays a role if you install the project, which you are not doing it (and that’s ok, you are using the build tree, not the install tree). And by the way, not good to set CMAKE_INSTALL_PREFIX to the source folder, choose any other folder to install it, or leave the default value.

itkVTKImageToImageFilter.h you need to install VTK for this (or build it), and provide a VTK_DIR to your build of ITK. Please read documentation and other posts about bridging VTK with ITK.

1 Like