# Rebuilding custom loadable extension that is part of SlicerCAT

**URL:** <https://discourse.slicer.org/t/rebuilding-custom-loadable-extension-that-is-part-of-slicercat/19942>\
**Category:** Development\
**Created:** [September 30, 2021, 11:45pm UTC](https://discourse.slicer.org/t/rebuilding-custom-loadable-extension-that-is-part-of-slicercat/19942 "2021-09-30T23:45:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![keri](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/keri/32/11618_2.png) [@keri](https://discourse.slicer.org/u/keri)\
**Post date:** [September 30, 2021, 11:45pm UTC](https://discourse.slicer.org/t/rebuilding-custom-loadable-extension-that-is-part-of-slicercat/19942/1 "2021-09-30T23:45:22Z")

</div>

Hi,

I’m working on loadable extension and I after successively built SlicerCAT I want to edit my extension source code and rebuild it.

The extension is added to the SlicerCAT via `FetchContent_Populate`.  
Then I can see that in build dir there is my extension source code and extension is build in `Slicer-build/E/MyExtension`.

Then I do something like:

```bash
cd ~/SlicerCAT/d/Slicer-build/E/MyExtension
cmake ../../../MyExtension -DSlicer_DIR=../..

```

but I get error when configuring:

```auto
CMake Error at ~/Documents/Colada/d/slicersources-src/CMake/SlicerMacroBuildModuleVTKLibrary.cmake:120 (add_library):
  add_library cannot create target "vtkSlicerStackLoadModuleLogic" because an
  imported target with the same name already exists.
Call Stack (most recent call first):
  ~/Documents/Colada/d/slicersources-src/CMake/SlicerMacroBuildModuleLogic.cmake:98 (SlicerMacroBuildModuleVTKLibrary)
  StackLoad/Logic/CMakeLists.txt:20 (SlicerMacroBuildModuleLogic)

```

Thus I can’t rebuilt extension to the dir where SlicerCAT expects loadable modules to be built.  
It is highly likely that I can build my extension to different folder then set Slicer to import modules from that folder and delete previous (default) build files but that would be pretty awkward…

By the way I understand that these targets are defined in `SlicerTargets.cmake` and they should be loaded (all together with `SlicerConfig.cmake`) when `find(Slicer REQUIRED)` is processed but I can’t understand how to avoid the error.

For now I work on Ubuntu 20.04 with GCC 9.3  
My custom app [GitHub - tierra-colada/Colada: Geophysical software (in progress)](https://github.com/tierra-colada/Colada)  
The extension [GitHub - tierra-colada/Seismic: Slicer 3D extension for seismic modules](https://github.com/tierra-colada/Seismic)

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [October 1, 2021, 4:18am UTC](https://discourse.slicer.org/t/rebuilding-custom-loadable-extension-that-is-part-of-slicercat/19942/2 "2021-10-01T04:18:03Z")

</div>

If Slicer already builds your custom modules then you must not build your modules as an extension, because it would want to add the same targets that you already have in your Slicer build. Just run make in the appropriate folder to build Slicer, including your modules.
