# Incremental rebuild of custom (SlicerCAT) application

**URL:** <https://discourse.slicer.org/t/incremental-rebuild-of-custom-slicercat-application/31432>\
**Category:** Development\
**Created:** [August 29, 2023, 1:30pm UTC](https://discourse.slicer.org/t/incremental-rebuild-of-custom-slicercat-application/31432 "2023-08-29T13:30:49Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![darabi](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/darabi/32/66736_2.png) [@darabi](https://discourse.slicer.org/u/darabi)\
**Post date:** [August 29, 2023, 1:30pm UTC](https://discourse.slicer.org/t/incremental-rebuild-of-custom-slicercat-application/31432/1 "2023-08-29T13:30:49Z")

</div>

Hello,  
when I change something in my SlicerCAT based custom application, I would like to make an incremental build, such that only those changed parts are updated/compiled.

However, running `make` in the `$BUILD_DIR/Slicer-build` directory starts to re-generate wrappers, re-compile a lot of `.cxx` files and re-link a lot of shared libs and binaries, e.g.:

```auto
...

Consolidate compiler generated dependencies of target MRMLLogic
[32%] Building CXX object Libs/MRML/Logic/CMakeFiles/MRMLLogic.dir/vtkMRMLAbstractLogic.cxx.o
[32%] Building CXX object Libs/MRML/Logic/CMakeFiles/MRMLLogic.dir/vtkMRMLApplicationLogic.cxx.o
[32%] Building CXX object Libs/MRML/Logic/CMakeFiles/MRMLLogic.dir/vtkMRMLColorLogic.cxx.o
[33%] Building CXX object Libs/MRML/Logic/CMakeFiles/MRMLLogic.dir/vtkMRMLDisplayableHierarchyLogic.cxx.o
[33%] Building CXX object Libs/MRML/Logic/CMakeFiles/MRMLLogic.dir/vtkMRMLRemoteIOLogic.cxx.o
[33%] Building CXX object Libs/MRML/Logic/CMakeFiles/MRMLLogic.dir/vtkMRMLLayoutLogic.cxx.o
[33%] Building CXX object Libs/MRML/Logic/CMakeFiles/MRMLLogic.dir/vtkMRMLSliceLayerLogic.cxx.o
[33%] Building CXX object Libs/MRML/Logic/CMakeFiles/MRMLLogic.dir/vtkMRMLSliceLogic.cxx.o
[33%] Building CXX object Libs/MRML/Logic/CMakeFiles/MRMLLogic.dir/vtkMRMLSliceLinkLogic.cxx.o
[33%] Building CXX object Libs/MRML/Logic/CMakeFiles/MRMLLogic.dir/vtkMRMLViewLogic.cxx.o
[33%] Building CXX object Libs/MRML/Logic/CMakeFiles/MRMLLogic.dir/vtkMRMLViewLinkLogic.cxx.o
[33%] Linking CXX shared library ../../../bin/libMRMLLogic.so
[33%] Built target MRMLLogic

```

and then it continues with a lot of other targets:

```auto
Consolidate compiler generated dependencies of target MRMLLogicCxxTests
...
Consolidate compiler generated dependencies of target MRMLDisplayableManager
...
Consolidate compiler generated dependencies of target MRMLDisplayableManagerPython
...
Consolidate compiler generated dependencies of target MRMLDisplayableManagerCxxTests
...

```

I’m not a CMake expert and the generated Makefiles are far too complex and contain too many targets for my limited make-foo.

Is there a way of rebuilding without this time-consuming compilation step?

Thank you

Kambiz

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [August 29, 2023, 1:44pm UTC](https://discourse.slicer.org/t/incremental-rebuild-of-custom-slicercat-application/31432/2 "2023-08-29T13:44:45Z")

</div>

You find the directories corresponding to each target in the subfolders. For example if you have a Widgets target within your custom app it is here: [SuperBuildPath]\Slicer-build\E[CustomAppName]\Widgets

You can run make from that folder on Linux or build the vcxproj if you’re on Windows.

I had to made a bunch of assumptions so let me know if this helped…

---

<div class="post-metadata">

**Author:** ![darabi](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/darabi/32/66736_2.png) [@darabi](https://discourse.slicer.org/u/darabi)\
**Post date:** [August 29, 2023, 2:42pm UTC](https://discourse.slicer.org/t/incremental-rebuild-of-custom-slicercat-application/31432/3 "2023-08-29T14:42:19Z")

</div>

Hi Csaba,  
thank you for your help and sorry for the incomplete information: I’m on Ubuntu 22.04 with gcc 11.4.

I do have a directory `SuperBuildPath/Slicer-build/E/` (not `ECustomAppName`) and in that directory, I find the `Home` module from the source tree `Modules/Scripted/` directory **plus** the modules and extensions which I added in my top-level `CMakeLists.txt` file.

When I add a new module, I probably have to re-run cmake to generate the Makefile. Will that lead to a recompile of the other (unrelated) parts?

Thanks

Kambiz

---

<div class="post-metadata">

**Author:** ![cpinter](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/cpinter/32/7995_2.png) [@cpinter](https://discourse.slicer.org/u/cpinter)\
**Post date:** [August 29, 2023, 3:12pm UTC](https://discourse.slicer.org/t/incremental-rebuild-of-custom-slicercat-application/31432/4 "2023-08-29T15:12:17Z")

</div>

I haven’t found a way to re-run CMake without running the superbuild. However, this does not bother me, because 1) adding new modules is not an everyday task, 2) If you’re in a hurry you can copy the new Python source files (only if the module is a scripted one of course) to [SuperBuildPath]\Slicer-build\lib[CustomAppName]-5.5\qt-scripted-modules and just start your application, which will instantiate the new module because it found the new .py file.

Just in case it helps: usually when I develop in Python I don’t run any build, but run a script that copies the source files to the appropriate directory in the superbuild. Some people change the AdditionalModulePaths in the ini file to point to their source codes, but I found that limiting. Still others make the Python changes directly in the superbuild and then copy those to the working copy of the source code, but I’m too cautious for that (a build would make those changes disappear).

---

<div class="post-metadata">

**Author:** ![ebrahim](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ebrahim/32/13403_2.png) [@ebrahim](https://discourse.slicer.org/u/ebrahim)\
**Post date:** [August 29, 2023, 3:56pm UTC](https://discourse.slicer.org/t/incremental-rebuild-of-custom-slicercat-application/31432/5 "2023-08-29T15:56:16Z")

</div>

> [@cpinter](#):
>
> If you’re in a hurry you can copy the new Python source files (only if the module is a scripted one of course) to [SuperBuildPath]\Slicer-build\lib[CustomAppName]-5.5\qt-scripted-modules and just start your application, which will instantiate the new module because it found the new .py file.

and there are these handy build targets to achieve this copy as well:

```auto
cmake --build ~/customapp-superbuild/Slicer-build --target CopySlicerPythonScriptFiles
cmake --build ~/customapp-superbuild/Slicer-build --target CopySlicerPythonResourceFiles

```

---

<div class="post-metadata">

**Author:** ![darabi](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/darabi/32/66736_2.png) [@darabi](https://discourse.slicer.org/u/darabi)\
**Post date:** [August 30, 2023, 10:03am UTC](https://discourse.slicer.org/t/incremental-rebuild-of-custom-slicercat-application/31432/6 "2023-08-30T10:03:56Z")

</div>

Thank you for your helpful tricks @cpinter and @ebrahim!
