Minimal VTK build with new module system

I guess this might be related to the module systems, but not really sure. I am trying to build on top of VTK libraries, where I generally like to reuse my ParaView compilation. Starting with some more recent version (for me that is pv 5.7 or later), the dependent library fails to load with the complaint:

undefined symbol: _ZN8vtkActor3NewEv

Which module do I need to add to the required components? Or does it have to be added to target_link_libraries instead/as well?

Looking through the linked docs, I also located Rendering/Core/vtk.module which looks like it might be useful, but neither find_package(ParaView REQUIRED COMPONENTS RenderingCore) or find_package(ParaView REQUIRED COMPONENTS VTK::RenderingCore) will even configure.
I obviously have no clue what I am doing, but I would like to improve!

FWIW an ldd dump of what is registered as being linked:

find_package(ParaView) ends up bringing in all of VTK because it does a naked find_package(VTK). I’d like to fix that eventually. It looks like you need to link to VTK::RenderingCore in your target_link_libraries.

Note that you can do a find_package(VTK) rather than searching for ParaView (though you might need to set VTK_DIR manually due to the way ParaView vendors VTK’s CMake files). Then find_package(VTK COMPONENTS RenderingCore) would get you what you need.

I tried this a long time ago, but remember there being something that didn’t quite resolve properly when VTK was coming via ParaView, or just gave up trying to navigate down to the correct paraview-x.y directory. Don’t really remember.

After vtkActor now being found, a bit of cat and mouse with other bits. vtkScalarBarActor seems to be next.

I recommend searching the VTK source tree for the associated header. Once you find it, the neighboring vtk.module will tell you the module name you need (instead of one-by-one stepping over Discourse :slight_smile: ).

1 Like

Hi @ben.boeckel - can’t let you off so easily after your last quip:

Finished my list of items and looks generally ok. Since the library created is my final target (will be loaded but not linked to), it seems that PRIVATE is enough as well.

EDIT: yes, there is no question there, but it could be, if someone volunteers an answer.

Yes, PRIVATE is sufficient for executables. As for the quip, I was just trying to avoid the “next class?” comment iteration here (it’s what I was doing here anyways since I can’t remember all of the class/module associations).

I’ll note that since you’re using VTK::RenderingCore, you should also call vtk_module_autoinit in order to make the object factories pull the right implementations.

1 Like

I like the VTK configure system quite a lot, with WANT and DONT_WANT. But it seems not to work for me as I would hope for, with VTK 9.1.0. There are a lot of errors that modules can not be found, but I did not force them to OFF, just set them to DONT_WANT.

However, my foremost question is: How can I debug why a module wants to be enabled? I’ve tried "-DVTK_DEBUG_MODULE=all", "-DVTK_DEBUG_MODULE_ALL=ON" and "-DVTK_DEBUG_MODULE_enable=ON" but there is just no output saying something like “module x enabled as a dependency of y”. I fail to see why for example IOExodus is enabled despite me setting all IO modules to DONT_WANT.

Ok I think I found the right option. When I enable all three of "-DVTK_DEBUG_MODULE=all" , "-DVTK_DEBUG_MODULE_ALL=ON" and "-DVTK_DEBUG_MODULE_enable=ON" at the same time, I see the desired output. Now I can debug enable/disable of the modules. Not sure if all three options are needed, but somehow I could not find the right option before.

Thanks for the nice build system!

You found the right options I see, but DONT_WANT is just a “I don’t need this, but if something else does, feel free to build it”. To force it off, use NO. I suspect something from testing enabled it.