# Failures due to build order of Slicer CAT with superbuild remote modules

**URL:** <https://discourse.slicer.org/t/failures-due-to-build-order-of-slicer-cat-with-superbuild-remote-modules/21841>\
**Category:** Support\
**Created:** [February 7, 2022, 4:14pm UTC](https://discourse.slicer.org/t/failures-due-to-build-order-of-slicer-cat-with-superbuild-remote-modules/21841 "2022-02-07T16:14:23Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![jamesobutler](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jamesobutler/32/7511_2.png) [@jamesobutler](https://discourse.slicer.org/u/jamesobutler)\
**Post date:** [February 7, 2022, 4:14pm UTC](https://discourse.slicer.org/t/failures-due-to-build-order-of-slicer-cat-with-superbuild-remote-modules/21841/1 "2022-02-07T16:14:23Z")

</div>

For a Slicer CAT (Custom application) that specifies additional remote extension in the main CMakeLists.txt and these remote modules are superbuild type extensions, how should I specify appropriate build dependencies for these extensions?

Currently some of the remote extensions I’ve been playing around with require VTK, ITK, and Python projects from the main Slicer core to be built first. This is not a problem when building the extension after the main Slicer core build finishes because all of these dependencies are already complete. However when building these superbuild remote extensions as part of a Slicer CAT with the /MP (multiple processes) flag on, these superbuild projects of these remote extensions are attempted and the build fails because it has not yet completed the Slicer core projects of VTK, ITK, and Python. Using the /MP flag is helpful on Windows and works well with Slicer core to reduce the total build time so I would like to continue to use this build optimization.

One specific example of a remote superbuild extension is [SlicerOpenIGTLink](https://github.com/openigtlink/SlicerOpenIGTLink). It has superbuild projects such as OpenIGTLinkIO which depends on VTK and YASM which depends on Python. I have observed YASM starting too early in the build process and then failing.

Another example is remote superbuild extension [SlicerOpenCV](https://github.com/Slicer/SlicerOpenCV). It has a superbuild project of ITKVideoBridgeOpenCV which depends on the main ITK project. I have observed ITKVideoBridgeOpenCV starting too early in the build process and then failing.

---

<div class="post-metadata">

**Author:** ![Sam\_Horvath](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/sam_horvath/32/3092_2.png) [@Sam\_Horvath](https://discourse.slicer.org/u/Sam_Horvath)\
**Post date:** [February 7, 2022, 4:30pm UTC](https://discourse.slicer.org/t/failures-due-to-build-order-of-slicer-cat-with-superbuild-remote-modules/21841/2 "2022-02-07T16:30:25Z")

</div>

I have done this for various projects, but always in a hack/workaround fashion by adding the dependency info myself.

In general what is needed is that the External\_Project files in the extension should be able to detect when they are being included in an application superbuild, and then add their depedencies.

I.e, at this line:

> <https://github.com/Slicer/SlicerOpenCV/blob/a93d759cac5cbd0aedf74e00e4a86d8cb96816b9/SuperBuild/External_ITKVideoBridgeOpenCV.cmake#L8>

ITK etc should be included if we are doing a custom app. As a workaround hack, you can create a fork/branch of the extension that has the additional dependency info, ex:

> <https://github.com/sjh26/SlicerOpenIGTLink/commit/0053222ec5da7b774320bb12e3b2a194d370c8fa>

---

<div class="post-metadata">

**Author:** ![jamesobutler](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jamesobutler/32/7511_2.png) [@jamesobutler](https://discourse.slicer.org/u/jamesobutler)\
**Post date:** [February 7, 2022, 7:52pm UTC](https://discourse.slicer.org/t/failures-due-to-build-order-of-slicer-cat-with-superbuild-remote-modules/21841/3 "2022-02-07T19:52:49Z")

</div>

I found the following example which may be the way to update extensions source without having to maintain a fork with the hack.

> <https://github.com/openigtlink/SlicerOpenIGTLink/commit/05fc59ed0a20a65a012337a8ff230e0d0d532fbb>
>
> This commit adds VTK as dependency when the OpenIGTLinkIO external project
> is bu…ilt in a Slicer custom application.
> 
> Co-authored-by: Sam Horvath \<sam.horvath@kitware.com\>

Also here was my original post on this topic from a couple years back. [SlicerOpenIGTLink causing CustomApp build to fail](https://discourse.slicer.org/t/sliceropenigtlink-causing-customapp-build-to-fail/7758)

---

<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:** [February 7, 2022, 8:36pm UTC](https://discourse.slicer.org/t/failures-due-to-build-order-of-slicer-cat-with-superbuild-remote-modules/21841/4 "2022-02-07T20:36:29Z")

</div>

Exactly, extensions having external project dependencies that are required only when “bundled” should be specified using this pattern:

```cmake
if(DEFINED Slicer_SOURCE_DIR)
  list(APPEND ${proj}_DEPENDS
    NameOfExternalProject1
    NameOfExternalProject2
    ...
    )
endif()

```

Then, when bundled it is sometime useful to exclude all the external projects or only consider a subset. This could be done setting variables like:  
`${extension_name}_EXTERNAL_PROJECT_EXCLUDE_ALL` or `${extension_name}_EXTERNAL_PROJECT_DEPENDENCIES`

### Bundling of “SuperBuild-type” extension

It also sensible to read the following:

> <https://github.com/Slicer/Slicer/blob/6db0afbb7d29a9fc7e8340a862f7346241647383/CMakeLists.txt#L1103-L1126>

#### Example of use of `${extension_name}_EXTERNAL_PROJECT_EXCLUDE_ALL`

> <https://github.com/Kitware/SlicerSALT/blob/7c76079d394cc036ffc704eef4ba88657607e80f/CMakeLists.txt#L338-L353>

### Use of the `SuperBuildPrerequisites.cmake` pattern

More recently, we introduced a new pattern consisting in adding a file called `SuperBuildPrerequisites.cmake` in the extension, and including it in custom application at configuration time.

This is useful to avoid duplicating requirements.

#### SlicerSMTK

\_while bundling case has been tested ✅ , the standalone build is still a work in progress ⌛ \_

The `SlicerMSTK/SuperBuildPrerequisites.cmake` file:

- [Verifying connection...](https://gitlab.kitware.com/aeva/slicersmtk/-/blob/feat-create-minimum-viable-plugin/SuperBuildPrerequisites.cmake)

… and how it is integrated in the custom application:

- [Verifying connection...](https://gitlab.kitware.com/shreeraj.jadhav/aevaslicer/-/blob/a3cb6208059ce3a4d8dec1bbf26b714f2590afc1/CMakeLists.txt#L209-221)

#### SlicerIMSTK

References:

- [https://github.com/jcfr/SlicerIMSTK/tree/support-custom-app-bundling-and-standalone-extension-build#readme](https://github.com/jcfr/SlicerIMSTK/tree/support-custom-app-bundling-and-standalone-extension-build#readme)
- [https://github.com/jcfr/SlicerIMSTK/blob/support-custom-app-bundling-and-standalone-extension-build/SuperBuildPrerequisites.cmake](https://github.com/jcfr/SlicerIMSTK/blob/support-custom-app-bundling-and-standalone-extension-build/SuperBuildPrerequisites.cmake)

Worth noting that `SuperBuildPrerequisites.cmake` defines `SlicerIMSTK_EXTERNAL_PROJECT_DEPENDENCIES`

---

<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:** [February 7, 2022, 9:45pm UTC](https://discourse.slicer.org/t/failures-due-to-build-order-of-slicer-cat-with-superbuild-remote-modules/21841/5 "2022-02-07T21:45:53Z")

</div>

> [@jcfr](#):
>
> Exactly, extensions having external project dependencies that are required only when “bundled” should be specified using this pattern:
> 
> ```auto
> if(DEFINED Slicer_SOURCE_DIR)
> list(APPEND ${proj}_DEPENDS
> NameOfExternalProject1
> NameOfExternalProject2
> ...
> )
> endif()
> 
> ```

Could we put this pattern inside `ExternalProject_Include_Dependencies`? To me it looks like a bug in `ExternalProject_Include_Dependencies` that it always enforces existence of `External_ITK.cmake` even if it is not needed. I think we could solve the issues by adding a check in `ExternalProject_Include_Dependencies` that would prevent the function from looking for `External_ITK.cmake` if `ITK_FOUND` is already set, similarly how it is done here:

> <https://github.com/lassoan/SlicerSegmentMesher/blob/4315b7b5ab34a6464bbf3c53fac0e9862fa6be55/SuperBuild/External_cleaver.cmake#L5-L9>

I guess by introducing a new `SuperBuildPrerequisites.cmake` file we could do more, but things are already so complex that we should really try to avoid adding a new mechanism to make things any more powerful, nicer, and generic and instead we should striving to make this simpler, less flexible, less configurable if at all possible.

> [@jamesobutler](#):
>
> Using the /MP flag is helpful on Windows and works well with Slicer core to reduce the total build time

If we want to make the Windows build faster I would not bother with the mere 20-30% speedup that `/MP` can do, because it rarely, if ever makes a difference - build takes hours either way. However, if we can reach the 30-minute full build from scratch (as on Linux) then it would worth investing time into developing and supporting that build option. Making Windows builds significantly faster using Ninja [came up a few years ago](https://discourse.slicer.org/t/msvc-cmake-cxx-mp-flag-default-value/1786/5), and interestingly nested external project builds caused the problems with that, too. If making things more complicated is inevitable then at least we should check if we can get other benefits out of it, such as faster builds.

---

<div class="post-metadata">

**Author:** ![jamesobutler](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jamesobutler/32/7511_2.png) [@jamesobutler](https://discourse.slicer.org/u/jamesobutler)\
**Post date:** [February 8, 2022, 2:05pm UTC](https://discourse.slicer.org/t/failures-due-to-build-order-of-slicer-cat-with-superbuild-remote-modules/21841/6 "2022-02-08T14:05:21Z")

</div>

I have had some success upon using the following changes in these PRs. I’m still having issues with SlicerOpenCV in the ITKVideoBridgeOpenCV project.

> <https://github.com/openigtlink/SlicerOpenIGTLink/pull/118>
>
> This adds some explicit dependencies to superbuild projects so that these projec…ts build successfully when part of a Slicer custom app build process with the /MP (multiple processes) build flag enabled. Without these changes, these projects would fail early as their dependent external projects from Slicer core had not finished yet.
> 
> Changes based on discussion at https://discourse.slicer.org/t/failures-due-to-build-order-of-slicer-cat-with-superbuild-remote-modules/21841
> 
> This supersedes https://github.com/openigtlink/SlicerOpenIGTLink/pull/94

> <https://github.com/IGSIO/SlicerIGSIO/pull/16>
>
> This adds some explicit dependencies to superbuild projects so that these projec…ts build successfully when part of a Slicer custom app build process with the /MP (multiple processes) build flag enabled. Without these changes, these projects would fail early as their dependent external projects from Slicer core had not finished yet.
> 
> Changes based on discussion at https://discourse.slicer.org/t/failures-due-to-build-order-of-slicer-cat-with-superbuild-remote-modules/21841

---

<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:** [February 8, 2022, 2:31pm UTC](https://discourse.slicer.org/t/failures-due-to-build-order-of-slicer-cat-with-superbuild-remote-modules/21841/7 "2022-02-08T14:31:47Z")

</div>

Yes, it seems that the same check is needed in every superbuild-type extensions.

@jcfr is there a specific reason that you recommended changing every `External_*.cmake` in every superbuild-type extension instead of fixing `SuperBuildPrerequisites.cmake`?

---

<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:** [February 8, 2022, 5:49pm UTC](https://discourse.slicer.org/t/failures-due-to-build-order-of-slicer-cat-with-superbuild-remote-modules/21841/8 "2022-02-08T17:49:30Z")

</div>

Following [2022.02.08 Weekly Meeting](https://discourse.slicer.org/t/2022-02-08-weekly-meeting/21843) discussion, we considered the following options:

1. Add a “virtual” project called `Slicer Dependencies` that would depend on all Slicer external project and ensure external projects from bundled SuperBuild extensions systematically depend on it.

2. Update `ExternalProjectDependency.cmake` to support customizing dependency of any external project.

We will move forward with approach (2)

### ExternalProject\_Add\_Dependencies

The good news is that the `ExternalProjectDependency` API already provide a function to do so:

[ExternalProject\_Add\_Dependencies](https://cmake-artichoke.readthedocs.io/en/latest/ExternalProjectDependency.html#function:ExternalProject_Add_Dependencies)

This means that custom application integrator should be able to address the integration of the issue specfic to `SlicerOpenCV` by adding:

```auto
ExternalProject_Add_Dependencies(ITKVideoBridgeOpenCV
  DEPENDS
    ITK
  )

```

### Path forward

This means that for now we have the flexibility of either updating extension or customizing the external project dependency graph when bundling extension in custom application.

---

<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:** [February 8, 2022, 7:55pm UTC](https://discourse.slicer.org/t/failures-due-to-build-order-of-slicer-cat-with-superbuild-remote-modules/21841/9 "2022-02-08T19:55:39Z")

</div>

Thank you @jcfr for working on this. Just one question:

If there is a project has dependencies that are provided in the Slicer core (ITK, VTK, DCMTK, etc.) then we need to add them using `ExternalProject_Add_Dependencies(${proj} DEPENDS ...)`; and add other libraries (zmq, pybind11, xeus, etc.) using `SET(${proj}_DEPENDS ...)`?

---

<div class="post-metadata">

**Author:** ![jamesobutler](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/jamesobutler/32/7511_2.png) [@jamesobutler](https://discourse.slicer.org/u/jamesobutler)\
**Post date:** [February 8, 2022, 9:07pm UTC](https://discourse.slicer.org/t/failures-due-to-build-order-of-slicer-cat-with-superbuild-remote-modules/21841/10 "2022-02-08T21:07:28Z")

</div>

Adding lines like the following appear to work to avoid having to update my custom application to now use the latest versions of extensions with my recently pushed updates.

```auto
ExternalProject_Add_Dependencies(OpenIGTLink
  DEPENDS
    ITK
  )

```

The ITKVideoBridgeOpenCV project is still failing for me because of a `numpy` location check that is in the initial configuration. I observed the CMake message `numpy package not found in python distribution. OpenCV python bindings won't be generated.` at time of configuring my custom application. Since this check for `numpy` location is done at time of configure rather than at time of the project beginning after ITK/python/python-numpy projects have finished, then it fails to appropriately build OpenCV as ITKVideoBridgeOpenCV needs.

> <https://github.com/Slicer/SlicerOpenCV/blob/a93d759cac5cbd0aedf74e00e4a86d8cb96816b9/SuperBuild/External_OpenCV.cmake#L50-L62>

```auto
46>CMake Warning at C:/SApp/OpenCV-install/OpenCVConfig.cmake:166 (message):
46> Found OpenCV Windows Pack but it has no binaries compatible with your
46> configuration.
46>
46> You should manually point CMake variable OpenCV_DIR to your build of OpenCV
46> library.
46>Call Stack (most recent call first):
46> itk-module-init.cmake:4 (find_package)
46> CMakeLists.txt:14 (include)
46>
46>
46>CMake Error at itk-module-init.cmake:4 (find_package):
46> Found package configuration file:
46>
46> C:/SApp/OpenCV-install/OpenCVConfig.cmake
46>
46> but it set OpenCV_FOUND to FALSE so package "OpenCV" is considered to be
46> NOT FOUND.
46>Call Stack (most recent call first):
46> CMakeLists.txt:14 (include)
46>
46>
46>-- Configuring incomplete, errors occurred!
46>See also "C:/SApp/ITKVideoBridgeOpenCV-build/CMakeFiles/CMakeOutput.log".
46>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(241,5): error MSB8066: Custom build for 'C:\SApp\CMakeFiles\320ab9882e45cf6a908302c3985d3202\ITKVideoBridgeOpenCV-mkdir.rule;C:\SApp\CMakeFiles\320ab9882e45cf6a908302c3985d3202\ITKVideoBridgeOpenCV-download.rule;C:\SApp\CMakeFiles\320ab9882e45cf6a908302c3985d3202\ITKVideoBridgeOpenCV-update.rule;C:\SApp\CMakeFiles\320ab9882e45cf6a908302c3985d3202\ITKVideoBridgeOpenCV-patch.rule;C:\SApp\CMakeFiles\320ab9882e45cf6a908302c3985d3202\ITKVideoBridgeOpenCV-configure.rule;C:\SApp\CMakeFiles\320ab9882e45cf6a908302c3985d3202\ITKVideoBridgeOpenCV-build.rule;C:\SApp\CMakeFiles\320ab9882e45cf6a908302c3985d3202\ITKVideoBridgeOpenCV-install.rule;C:\SApp\CMakeFiles\d0f4a9b23d08a9ea69be4fa4694697b0\ITKVideoBridgeOpenCV-complete.rule;C:\SApp\CMakeFiles\daf1effa4b5847d53d90fb6a3d2334b3\ITKVideoBridgeOpenCV.rule;C:\SApp\slicersources-src\CMakeLists.txt' exited with code 1.
46>Done building project "ITKVideoBridgeOpenCV.vcxproj" -- FAILED.

```

---

<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:** [February 8, 2022, 10:03pm UTC](https://discourse.slicer.org/t/failures-due-to-build-order-of-slicer-cat-with-superbuild-remote-modules/21841/11 "2022-02-08T22:03:06Z")

</div>

### SlicerJupyter use-case custom application bundling use-case

> [@lassoan](#):
>
> If there is a project has dependencies that are provided in the Slicer core (ITK, VTK, DCMTK, etc.) then we need to add them using `ExternalProject_Add_Dependencies(${proj} DEPENDS ...)` ; and add other libraries (zmq, pybind11, xeus, etc.) using `SET(${proj}_DEPENDS ...)` ?

There is no need to specify additional `set(${proj}_DEPENDS ..)`

To make things concrete, bundling `SlicerJupyter` would only require the following in the custom application top-level `CMakeLists.txt`:

```cmake
# SlicerJupyter
set(extension_name "SlicerJupyter")
set(${extension_name}_SOURCE_DIR "${CMAKE_BINARY_DIR}/${extension_name}")
FetchContent_Populate(${extension_name}
  SOURCE_DIR ${${extension_name}_SOURCE_DIR}
  GIT_REPOSITORY ${EP_GIT_PROTOCOL}://github.com/Slicer/SlicerJupyter.git
  GIT_TAG b282a2c819da1e3e4fe1ab6c419e2299f976720d
  GIT_PROGRESS 1
  QUIET
  )
list(APPEND Slicer_EXTENSION_SOURCE_DIRS ${${extension_name}_SOURCE_DIR})

ExternalProject_Add_Dependencies(pybind11
  DEPENDS
    python
  )

ExternalProject_Add_Dependencies(python-packages
  DEPENDS
    python
    python-pip
    python-setuptools
  )

```

The configuration output effectively indicates the dependencies are considered:

```bash
$ cmake -DCMAKE_BUILD_TYPE:STRING=Release -DQt5_DIR:PATH=$Qt5_DIR ../SlicerGalaxy
[...]
-- SuperBuild - python-packages => Requires python[INCLUDED], python-pip[INCLUDED], python-setuptools[INCLUDED], 
-- SuperBuild - python-packages[OK]
[...]
-- SuperBuild - pybind11 => Requires python[INCLUDED], 
-- SuperBuild - pybind11[OK]
[...]

```

#### Suggested SlicerJupyter updates

- There are some hard-coded instance of the string `lib/python3.6/site-packages` that should be removed. Instead the variable `PYTHON_SITE_PACKAGES_SUBDIR`should be used. This pull request should take care of this: [COMP: Fix python-packages external project removing hard-coded site-packages path by jcfr · Pull Request #67 · Slicer/SlicerJupyter · GitHub](https://github.com/Slicer/SlicerJupyter/pull/67)

- Considering `python-packages` project name is fairly generic and could conflict with other extension install python packages, we should rename it to `python-slicerjupyter-requirements`. This will be done after the previous pull-request has been integrated. It is tracked by this issue: [GitHub · Where software is built](https://github.com/Slicer/SlicerJupyter/issues/68)

- To provide some more flexibility, we should also look into adding  
`Slicer_REQUIRED_PYTHON_VERSION_DOT` recently introduced in [Slicer@e32fa814f](https://github.com/Slicer/Slicer/commit/e32fa814fecdc73cf817141ce0d36d0a088e3881) to `SlicerConfig.cmake.in`. This pull request takes care of this: [COMP: Add Slicer\_REQUIRED\_PYTHON\_VERSION\_\* variables to SlicerConfig by jcfr · Pull Request #6169 · Slicer/Slicer · GitHub](https://github.com/Slicer/Slicer/pull/6169)

---

<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:** [February 9, 2022, 2:07am UTC](https://discourse.slicer.org/t/failures-due-to-build-order-of-slicer-cat-with-superbuild-remote-modules/21841/12 "2022-02-09T02:07:10Z")

</div>

### SlicerOpenCV custom application bundling use-case

> [@jamesobutler](#):
>
> The ITKVideoBridgeOpenCV project is still failing for me because of a `numpy` location check that is in the initial configuration. I observed the CMake message `numpy package not found in python distribution. OpenCV python bindings won't be generated.` at time of configuring my custom application

The following pull-request simplify and fix the support for custom application bundling: [Simplify buildsystem by jcfr · Pull Request #69 · Slicer/SlicerOpenCV · GitHub](https://github.com/Slicer/SlicerOpenCV/pull/69)

In a nutshell, the introspection leading to the error you experienced should be done at build time. And it turns out this was already the case. An additional OpenCV patch was needed to make sure no attempt at finding Python2 was done (see ).

To illustrate the following should allows to bundle `SlicerOpenCV`:

_⚠ The example below currently references a fork because the pull request referenced above has not yet been integrated. Please, do not implement any production code relying a personal fork._

```cmake

# SlicerOpenCV
set(extension_name "SlicerOpenCV")
set(${extension_name}_SOURCE_DIR "${CMAKE_BINARY_DIR}/${extension_name}")
FetchContent_Populate(${extension_name}
  SOURCE_DIR ${${extension_name}_SOURCE_DIR}
  GIT_REPOSITORY ${EP_GIT_PROTOCOL}://github.com/jcfr/SlicerOpenCV.git
  GIT_TAG e2a86986482ba0da4f7b5ca2abe8e158a0f2a991
  GIT_PROGRESS 1
  QUIET
  )
list(APPEND Slicer_EXTENSION_SOURCE_DIRS ${${extension_name}_SOURCE_DIR})

# SlicerOpenCV: Add OpenCV dependencies specific to Slicer
ExternalProject_Add_Dependencies(OpenCV
  DEPENDS
    python-numpy
  )

# SlicerOpenCV: Overide list of dependencies to avoid attempt to build ITKVideoBridgeOpenCV
set(${extension_name}_EXTERNAL_PROJECT_DEPENDENCIES
  OpenCV
  )

# SlicerOpenCV: Enable ITKVideoBridgeOpenCV module
set(Module_ITKVideoBridgeOpenCV ON)
mark_as_superbuild(
  VARS
    Module_ITKVideoBridgeOpenCV:BOOL
    OpenCV_DIR:PATH # Set in External_OpenCV.cmake
  PROJECTS
    ITK
  )
ExternalProject_Add_Dependencies(ITK
  DEPENDS
    OpenCV
  )

```

---

<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:** [February 9, 2022, 2:18am UTC](https://discourse.slicer.org/t/failures-due-to-build-order-of-slicer-cat-with-superbuild-remote-modules/21841/13 "2022-02-09T02:18:46Z")

</div>

> [@jcfr](#):
>
> SlicerOpenCV custom application bundling use-case

You may also want to specify `VTK` since OpenCV is built with the option:

```diff
ExternalProject_Add_Dependencies(OpenCV
  DEPENDS
    python-numpy
+ VTK
  )

```
