I have a couple of projects that use VTK and would like to upgrade them to the new module system used with VTK 9, but am having difficulty with how I get them to link together.
Let’s say the projects are projectA and projectB. projectA - needs to link against VTK and I can compile this with the new module system(with python wrapping) using a procedure similar to vrkSRC/Examples/Wrapping/. The problem comes for projectB, the modules for projectB need to link against VTK, projectA as well as some third party libraries (e.g. LibXM2). I also need to be able to generate python bindings for projectB
How do I:
1- create a dependency for the installed modules from projectA in projectB
2- specify the linking to the third party libraries in projectB
You’ll need to write a projectA-config.cmake file so that projectB can do find_package(projectA). You can see the CMake/vtk-config.cmake.in file in VTK itself for how to set it up.
You can use LibXM2 just like any other external project, though you’ll need to likely export its find module to your CMake package. VTK does this in the VTK::FiltersOpenTURNS module.
You can see how it is done in ParaView, SMTK (which can use ParaView and also provides its own modules). Note that ParaView is a bit weird because it also provides VTK itself, but SMTK should have parts which match what you want to do.
Ok, I am having some progress with this but am having difficulty with how the python wrappings from project A are exported. My suspicion is that I need to make an equivalent of the vtkmodules-vtk-python-module-properties.cmake file but I cannot work out how to do so.
The current issue I have is as follows; projectA contains library X. Also I can compile project B library Y that has a dependency on A::X using the module structure and projectA-config.cmake. I can also successfully generate python bindings for both projects. However if I try to import from project B, for example:
Update - in case anyone else comes across this error. I needed to switch INSTALL_HEADERS to ON when calling vtk_module_wrap_python to get it to install things properly.