Cmake: impossible to open .h files


I tried to include vtk to code and to use it but it’s look like cmake was not able to find .h files.

i include VTK using this cmake code:

set(VTK_DIR "C:/vtk/VTK-9.2.6-install/lib/cmake/vtk-9.2/")
function(add_vtk libname)
    find_package(VTK REQUIRED)
    target_link_libraries( ${libname} PRIVATE ${VTK_LIBRARIES})

then in sub directory where i need vtk i just call the function and i put the name of the library.

I checked if VTK_LIBRARIES is not empty and it’s not.

Also, i was able to code a method using vtk without any error. visual studio have access to definitions of vtk objects as it’s showing me members of vtk objects but for an obscure reason when i push the button to launch it, after the cmake generation (which is going well), the code bug.

also, when i wrote:

vtkSmartPointer<vtkPlot> line = vtkSmartPointer<vtkPlot>::New()

the code return me an error like:

‘’ : impossible to convert from ‘initializer list’ into 'vtkSmartPointer

which redirect me to the vtkSmartPointer.h file…

I really dont get this magic.

someone have an idea before i burn my wizard computer?

thank you in advance !

Can you please provide the full source that you tried? This sounds like a missing #include, but it’s hard to say.

thank you.

I already solved it.

Include was not the problem. the problem was:

i had to add the add_vtk() in all cmakelists from the root to the subdirectory which contain the code.