# Build Slicer with custom VTK

**URL:** <https://discourse.slicer.org/t/build-slicer-with-custom-vtk/5552>\
**Category:** Development\
**Created:** [January 29, 2019, 2:53am UTC](https://discourse.slicer.org/t/build-slicer-with-custom-vtk/5552 "2019-01-29T02:53:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![drouin-simon](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/drouin-simon/32/258_2.png) [@drouin-simon](https://discourse.slicer.org/u/drouin-simon)\
**Post date:** [January 29, 2019, 2:53am UTC](https://discourse.slicer.org/t/build-slicer-with-custom-vtk/5552/1 "2019-01-29T02:53:35Z")

</div>

Hi all,

I am developing a new feature in the VolumeRendering module which involves some changes in VTK and I’m looking for the simplest way to build Slicer in that context.

My first instinct was to super-build Slicer, go to the VTK directory and checkout my own branch of VTK (which is ahead of the gitlab kitware vtk by a few commits) and rebuild only VTK, then Slicer. However, it seems the CMake cache of both VTKs is not compatible. The problem could be caused by the introduction of the new module system in VTK which I believe happened between the Slicer head and the gitlab.kitware head.

What is the easiest way to build my own VTK to be compatible with Slicer. There are quite a lot of parameters set in SuperBuild/External\_VTK.cmake. Are they all needed? Is there a shortcut that would save me some time? What are your tricks? @lassoan @cpinter @pieper

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [January 29, 2019, 3:35am UTC](https://discourse.slicer.org/t/build-slicer-with-custom-vtk/5552/2 "2019-01-29T03:35:13Z")

</div>

For any external project, you can pass the options:

- `Slicer_${proj}_GIT_REPOSITORY`
- `Slicer_${proj}_GIT_TAG`

For VTK, you can configure Slicer passing:

- `-DSlicer_VTK_GIT_REPOSITORY:STRING=https://... -DSlicer_VTK_GIT_TAG:STRING=origin/your-topic`

That said, considering VTK updated its build system in a backward incompatible way, it may not word as smoothly as you would expect …

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [January 29, 2019, 8:04am UTC](https://discourse.slicer.org/t/build-slicer-with-custom-vtk/5552/3 "2019-01-29T08:04:41Z")

</div>

Yes, unfortunately it may take a while to adapt Slicer to VTK’s new module system. In the mean time it’s probably easier to maintain your patches in a fork of [github.com/Slicer/VTK](http://github.com/Slicer/VTK) (and point your superbuild there) using the parameters Jc described.

---

<div class="post-metadata">

**Author:** ![drouin-simon](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/drouin-simon/32/258_2.png) [@drouin-simon](https://discourse.slicer.org/u/drouin-simon)\
**Post date:** [January 29, 2019, 1:44pm UTC](https://discourse.slicer.org/t/build-slicer-with-custom-vtk/5552/4 "2019-01-29T13:44:22Z")

</div>

Sounds good. I can backport the changes I made to VTK into a fork of the [github.com/Slicer/VTK](http://github.com/Slicer/VTK) repository to continue working.

But, what is the best course of action to propagate the changes forward? I’ve already submitted a merge request to VTK. Should I keep pushing them to merge it right away? Or should I try to merge the changes in [github.com/Slicer/VTK](http://github.com/Slicer/VTK) and then someone else will take care of merging this back to the official VTK?

---

<div class="post-metadata">

**Author:** ![jcfr](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jcfr/32/17825_2.png) [@jcfr](https://discourse.slicer.org/u/jcfr)\
**Post date:** [January 29, 2019, 3:16pm UTC](https://discourse.slicer.org/t/build-slicer-with-custom-vtk/5552/5 "2019-01-29T15:16:38Z")

</div>

Ultimately you should make sure the changes are integrated in VTK proper , then we can easily backport into Slicer.
