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:

libvtkCommonCore-pv5.9.so.1
libvtkCommonDataModel-pv5.9.so.1
libvtkCommonExecutionModel-pv5.9.so.1
libvtkCommonMath-pv5.9.so.1
libvtkCommonMisc-pv5.9.so.1
libvtkCommonSystem-pv5.9.so.1
libvtkCommonTransforms-pv5.9.so.1
libvtkIOCore-pv5.9.so.1
libvtkIOLegacy-pv5.9.so.1
libvtkParallelCore-pv5.9.so.1
libvtkParallelMPI-pv5.9.so.1
libvtkdoubleconversion-pv5.9.so.1
libvtkloguru-pv5.9.so.1
libvtklz4-pv5.9.so.1
libvtklzma-pv5.9.so.1
libvtkpugixml-pv5.9.so.1
libvtksys-pv5.9.so.1
libvtkzlib-pv5.9.so.1

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.

I recently came across this thread while trying to solve the exact problem that the original post was posing: configuring a minimal VTK build. I wanted to clarify a few of the comments here so that this thread can help others in the future (including me).

VTK_BUILD_ALL_MODULES is used to control whether modules are built by default or not. It is an option (so, a boolean) and only accepts truthy/falsy values (e.g. ON/OFF). If it is set to one of non-YES/NO 5-state values (WANT, DEFAULT, DONT_WANT), then it will likely be treated as an ON even when that's not intended.

VTK_DEBUG_MODULE is another option/boolean flag that controls whether module debugging is enabled at all. However, by itself, it doesn't actually log anything. For that, you'll have to use either VTK_DEBUG_MODULE_ALL to enable logging from every module or one of VTK_DEBUG_MODULE_building, VTK_DEBUG_MODULE_enable, VTK_DEBUG_MODULE_kit, VTK_DEBUG_MODULE_module, VTK_DEBUG_MODULE_provide, VTK_DEBUG_MODULE_testing. These are also options/booleans, so only ON/OFF are supported.

If I run CMake with cmake -DVTK_BUILD_ALL_MODULES:BOOL=OFF -DVTK_DEBUG_MODULE:BOOL=ON -DVTK_DEBUG_MODULE_ALL:BOOL=ON then I'm able to get a minimal build and get logging statements that tell me exactly what is built. These logs are of the following form.

-- VTK module debug kit: VTK::Common declared by /home/me/vtk/source/Common/Core/vtk.kit
-- VTK module debug kit: VTK::Filters declared by /home/me/vtk/source/Filters/Core/vtk.kit
-- VTK module debug kit: VTK::Imaging declared by /home/me/vtk/source/Imaging/Core/vtk.kit
-- VTK module debug kit: VTK::Interaction declared by /home/me/vtk/source/Interaction/Style/vtk.kit
-- VTK module debug kit: VTK::IO declared by /home/me/vtk/source/IO/Core/vtk.kit
-- VTK module debug kit: VTK::Parallel declared by /home/me/vtk/source/Parallel/Core/vtk.kit
-- VTK module debug kit: VTK::Rendering declared by /home/me/vtk/source/Rendering/Core/vtk.kit
-- VTK module debug kit: VTK::OpenGL declared by /home/me/vtk/source/Rendering/OpenGL2/vtk.kit
-- VTK module debug kit: VTK::Views declared by /home/me/vtk/source/Views/Core/vtk.kit
-- VTK module debug module: VTK::AcceleratorsVTKmCore declared by /home/me/vtk/source/Accelerators/Vtkm/Core/vtk.module
-- VTK module debug enable: VTK::AcceleratorsVTKmCore is DEFAULT, using `WANT_BY_DEFAULT`: via `VTK_BUILD_ALL_MODULES`
-- VTK module debug module: VTK::AcceleratorsVTKmDataModel declared by /home/me/vtk/source/Accelerators/Vtkm/DataModel/vtk.module