# VTK Module system with mulitple projects

**URL:** https://discourse.vtk.org/t/vtk-module-system-with-mulitple-projects/3880
**Category:** Support
**Created:** [July 30, 2020, 3:55pm UTC](https://discourse.vtk.org/t/vtk-module-system-with-mulitple-projects/3880 "2020-07-30T15:55:28Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![kit](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/k/9fc29f/32.png) [@kit](https://discourse.vtk.org/u/kit)
#### Post date: [July 30, 2020, 3:55pm UTC](https://discourse.vtk.org/t/vtk-module-system-with-mulitple-projects/3880/1 "2020-07-30T15:55:28Z")

</div>

Hi,

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

Any help would be greatly appreciated

Thanks

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)
#### Post date: [July 30, 2020, 6:40pm UTC](https://discourse.vtk.org/t/vtk-module-system-with-mulitple-projects/3880/2 "2020-07-30T18:40:08Z")

</div>

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](https://gitlab.kitware.com/vtk/vtk/-/blob/master/Filters/OpenTURNS/CMakeLists.txt).

You can see how it is done in [ParaView](https://gitlab.kitware.com/paraview/paraview), [SMTK](https://gitlab.kitware.com/cmb/smtk/-/blob/master/smtk/extension/vtk/CMakeLists.txt) (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.

---

<div class="post-metadata">

### Author: ![kit](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/k/9fc29f/32.png) [@kit](https://discourse.vtk.org/u/kit)
#### Post date: [July 31, 2020, 2:47pm UTC](https://discourse.vtk.org/t/vtk-module-system-with-mulitple-projects/3880/3 "2020-07-31T14:47:22Z")

</div>

Thanks Ben, I will let you know how I get on

---

<div class="post-metadata">

### Author: ![kit](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/k/9fc29f/32.png) [@kit](https://discourse.vtk.org/u/kit)
#### Post date: [August 1, 2020, 2:22pm UTC](https://discourse.vtk.org/t/vtk-module-system-with-mulitple-projects/3880/4 "2020-08-01T14:22:28Z")

</div>

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:

` python3 -c "import B.Y"`

I get

` ImportError: Failed to load Y: No module named .X`

Any thoughts?

Thanks

Kit

---

<div class="post-metadata">

### Author: ![kit](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/k/9fc29f/32.png) [@kit](https://discourse.vtk.org/u/kit)
#### Post date: [August 3, 2020, 10:04am UTC](https://discourse.vtk.org/t/vtk-module-system-with-mulitple-projects/3880/5 "2020-08-03T10:04:13Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)
#### Post date: [August 4, 2020, 12:29pm UTC](https://discourse.vtk.org/t/vtk-module-system-with-mulitple-projects/3880/6 "2020-08-04T12:29:09Z")

</div>

It should default to `ON`, but I guess if you don’t pass `CMAKE_DESTINATION`, you get an error and the “easy” fix is to turn off header installation.
