# Extension dependencies in custom apps

**URL:** <https://discourse.slicer.org/t/extension-dependencies-in-custom-apps/23552>\
**Category:** Development\
**Tags:** build\
**Created:** [May 24, 2022, 8:59am UTC](https://discourse.slicer.org/t/extension-dependencies-in-custom-apps/23552 "2022-05-24T08:59:15Z")\
**Posts on this page:** 8\
**Page:** 1

<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:** [May 24, 2022, 8:59am UTC](https://discourse.slicer.org/t/extension-dependencies-in-custom-apps/23552/1 "2022-05-24T08:59:15Z")

</div>

Hi all,

Recently the SlicerIGT extension added a dependency to SlicerIGSIO. This is all good, but it made me face a situation in a custom app that I haven’t had to deal with before.

If an extension depends on another one, we need to define a variable, like `SlicerIGSIO_DIR`, and then SlicerIGT would find `SlicerIGSIOConfig.cmake` in that folder (I assume). However, in a custom app, the extension build directories differ from a normal extension build directory. There is no such cmake file for example.

Is there a way to force an extension to generate this cmake file? Or any suggestions how to move forward with this?

Thank you so much!

---

<div class="post-metadata">

**Author:** ![Sunderlandkyl](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/sunderlandkyl/32/79987_2.png) [@Sunderlandkyl](https://discourse.slicer.org/u/Sunderlandkyl)\
**Post date:** [May 24, 2022, 12:55pm UTC](https://discourse.slicer.org/t/extension-dependencies-in-custom-apps/23552/2 "2022-05-24T12:55:12Z")

</div>

Maybe we could add a check to SlicerIGT that would only call if it is not part of a custom build.

Does this change in SlicerIGT work?:

```auto
if (NOT DEFINED Slicer_EXTENSION_SOURCE_DIRS)
  find_package(SlicerIGSIO REQUIRED) 
endif()

```

---

<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:** [May 24, 2022, 1:11pm UTC](https://discourse.slicer.org/t/extension-dependencies-in-custom-apps/23552/3 "2022-05-24T13:11:33Z")

</div>

Thanks Kyle, a solution I haven’t considered. Wouldn’t it prevent SlicerIGT from using the algorithms in SlicerIGSIO it depends on?

---

<div class="post-metadata">

**Author:** ![Sunderlandkyl](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/sunderlandkyl/32/79987_2.png) [@Sunderlandkyl](https://discourse.slicer.org/u/Sunderlandkyl)\
**Post date:** [May 24, 2022, 1:22pm UTC](https://discourse.slicer.org/t/extension-dependencies-in-custom-apps/23552/4 "2022-05-24T13:22:37Z")

</div>

Good point. I think that since both SlicerIGT and SlicerIGSIO would be part of the build same build, it should be fine.

---

<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:** [May 24, 2022, 1:33pm UTC](https://discourse.slicer.org/t/extension-dependencies-in-custom-apps/23552/5 "2022-05-24T13:33:53Z")

</div>

OK let me try, thanks!

---

<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:** [May 24, 2022, 7:59pm UTC](https://discourse.slicer.org/t/extension-dependencies-in-custom-apps/23552/6 "2022-05-24T19:59:22Z")

</div>

Just as I suspected, without having found SlicerIGSIO the build fails with errors like this:

`E:\s\sR\SlicerIGT\LandmarkDetection\Logic\vtkSlicerLandmarkDetectionLogic.cxx(38,10): fatal error C1083: Cannot open include file: 'vtkIGSIOLandmarkDetectionAlgo.h': No such file or directory [E:\s\sR\Slicer-build\E\SlicerIGT\LandmarkDetection\Logic\vtkSlicerLandmarkDetectionModuleLogic.vcxproj] [E:\s\sR\slicersources-build\Slicer.vcxproj] `

Somehow we need to allow the discovery of the SlicerIGSIO sources and libraries within the custom app. What I can think of is to configure the `SlicerIGSIOConfig.cmake` file from an `.in` file and have that set all the variables.

Any other ideas @jcfr @lassoan ? If not then I’ll try with the `.in` configure approach. Thanks a lot!

---

<div class="post-metadata">

**Author:** ![Sunderlandkyl](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/sunderlandkyl/32/79987_2.png) [@Sunderlandkyl](https://discourse.slicer.org/u/Sunderlandkyl)\
**Post date:** [May 24, 2022, 8:17pm UTC](https://discourse.slicer.org/t/extension-dependencies-in-custom-apps/23552/7 "2022-05-24T20:17:05Z")

</div>

vtkIGSIOLandmarkDetectionAlgo is from IGSIO, not SlicerIGSIO. SlicerIGSIO probably pulled in the IGSIO libraries previously.

What if you use:

```auto
if (NOT DEFINED Slicer_EXTENSION_SOURCE_DIRS)
  find_package(SlicerIGSIO REQUIRED) 
else()
  find_package(IGSIO REQUIRED) 
endif()

```

---

<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:** [May 24, 2022, 9:43pm UTC](https://discourse.slicer.org/t/extension-dependencies-in-custom-apps/23552/8 "2022-05-24T21:43:49Z")

</div>

This makes a lot of sense, Kyle. I didn’t even think that these algorithms were in IGSIO not SliceriGSIO. I started a build and it seems to have gone past these. Will send a PR if it finishes without errors. Thank you!
