# How does CMake find all the dependencies installed by cmb-superbuild?

**URL:** https://discourse.kitware.com/t/how-does-cmake-find-all-the-dependencies-installed-by-cmb-superbuild/862
**Category:** Computational Model Builder (CMB)
**Created:** [July 14, 2022, 12:28am UTC](https://discourse.kitware.com/t/how-does-cmake-find-all-the-dependencies-installed-by-cmb-superbuild/862 "2022-07-14T00:28:52Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Yang](https://discourse.kitware.com/user_avatar/discourse.kitware.com/yang/32/556_2.png) [@Yang](https://discourse.kitware.com/u/Yang)
#### Post date: [July 14, 2022, 12:28am UTC](https://discourse.kitware.com/t/how-does-cmake-find-all-the-dependencies-installed-by-cmb-superbuild/862/1 "2022-07-14T00:28:52Z")

</div>

Dear CMB community,

I am using superbuild to build all the dependencies. I followed the [setup](https://gitlab.kitware.com/cmb/cmb-superbuild/-/blob/master/.gitlab/os-windows.yml) on Windows where `<path_to_cmb_superbuild_install>/install/bin` and `<path_to_cmb_superbuild_install>/install/Python` are added to PATH and `<path_to_cmb_superbuild_install>/install/Python` is also added to PYTHONHOME.  
After this, I can build CMB based application and execute it without any issue.

What I don’t understand is how CMake finds ParaView or SMTK or any other libraries which were built from superbuild. I only added `<path_to_cmb_superbuild_install>/install/bin` to PATH. There is a subfolder `cmake` under `<path_to_cmb_superbuild_install>/install/bin`. But it is empty. I see all the config.cmake files which find\_package() is looking for is inside `C:\cmb\RelWithDebInfo\install\lib\cmake`. But I didn’t even add `C:\cmb\RelWithDebInfo\install\lib` to my PATH.

Thanks,  
Yang

---

<div class="post-metadata">

### Author: ![aron.helser](https://discourse.kitware.com/user_avatar/discourse.kitware.com/aron.helser/32/149_2.png) [@aron.helser](https://discourse.kitware.com/u/aron.helser)
#### Post date: [July 14, 2022, 3:16pm UTC](https://discourse.kitware.com/t/how-does-cmake-find-all-the-dependencies-installed-by-cmb-superbuild/862/2 "2022-07-14T15:16:38Z")

</div>

Hi Yang,  
Basically this is just how the superbuild is setup to work. Each project in the superbuild is designed to install everything needed into the `build/install` directory, so that any project that depends on it can find the headers/libs needed. So ParaView puts all the headers, libs, dlls and binaries it built into the `install` dir, and then SMTK looks there because it is set up that way by the superbuild.

This convenience is broken for dependencies if you choose to do a “developer build”, because that project no longer installs its headers/libs into the superbuild’s `build/install` directory. So you need to tell any dependencies explicitly where that project is. For example, if you do a developer build of SMTK, if you then want to build aeva-session which depends on it, you would need to add `-Dsmtk_DIR:PATH=C:/cmb/smtk/build` with the SMTK build dir to your cmake command.

HTH,  
Aron

---

<div class="post-metadata">

### Author: ![Yang](https://discourse.kitware.com/user_avatar/discourse.kitware.com/yang/32/556_2.png) [@Yang](https://discourse.kitware.com/u/Yang)
#### Post date: [July 14, 2022, 4:48pm UTC](https://discourse.kitware.com/t/how-does-cmake-find-all-the-dependencies-installed-by-cmb-superbuild/862/3 "2022-07-14T16:48:27Z")

</div>

Thanks! I think I got it. To quote from find\_package() [documentation](https://cmake.org/cmake/help/latest/command/find_package.html), `Path entries ending in `/bin`or`/sbin` are automatically converted to their parent directories:` So, this is a cmake feature. I was scratching my head on why it finds `build/install/lib` as I only added `build/install/bin` to my PATH.

Regarding the developer build, if I choose developer mode, does it allow me to use Debug configuration? It seems like superbuild only supports Release and RelWithDebInfo

---

<div class="post-metadata">

### Author: ![aron.helser](https://discourse.kitware.com/user_avatar/discourse.kitware.com/aron.helser/32/149_2.png) [@aron.helser](https://discourse.kitware.com/u/aron.helser)
#### Post date: [July 14, 2022, 4:55pm UTC](https://discourse.kitware.com/t/how-does-cmake-find-all-the-dependencies-installed-by-cmb-superbuild/862/4 "2022-07-14T16:55:56Z")

</div>

The `PATH` environment variable is not used by CMake, I don’t think - it is just used when running your app to find DLLs. I think the docs are referring to `CMAKE_MODULE_PATH`, which is set by the superbuild.

As for using Debug, not on Windows, unfortunately - you must choose either the debug runtime or the release runtime consistently for all libraries in your project, otherwise you get linking errors. The best bet is to go with RelWithDebInfo for everything. This limitation does not apply on Mac/Linux.

---

<div class="post-metadata">

### Author: ![Yang](https://discourse.kitware.com/user_avatar/discourse.kitware.com/yang/32/556_2.png) [@Yang](https://discourse.kitware.com/u/Yang)
#### Post date: [July 14, 2022, 4:57pm UTC](https://discourse.kitware.com/t/how-does-cmake-find-all-the-dependencies-installed-by-cmb-superbuild/862/5 "2022-07-14T16:57:28Z")

</div>

I am having the issue which doesn’t load OpencascadeSession. I enabled OpenCascadeSession in superbuild and but when I loaded that plugin in the application, I got the following message.

 ![image](https://discourse.kitware.com/uploads/default/original/1X/be0dd22913451c98b93c19fb1512c8df79e681b0.png)

I am using RelWithDebInfo configuration and this message doesn’t help much. I was wondering that if debug configuration could throw out more information?

---

<div class="post-metadata">

### Author: ![Yang](https://discourse.kitware.com/user_avatar/discourse.kitware.com/yang/32/556_2.png) [@Yang](https://discourse.kitware.com/u/Yang)
#### Post date: [July 14, 2022, 5:30pm UTC](https://discourse.kitware.com/t/how-does-cmake-find-all-the-dependencies-installed-by-cmb-superbuild/862/6 "2022-07-14T17:30:45Z")

</div>

Then I don’t understand it.

when I build superbuild project, it will add `build/install/lib` to CMAKE\_MODULE\_PATH such that an external project, e.g., aeva-session, can find the dependencies. Is this correct?

I just tested it. If I removed build/install/bin from PATH and reconfigure aeva-session, it can’t find smtk package. What I have observed so far:  
`build/install/bin` in PATH environment variable → can find dependencies  
`build/install/bin` not in PATH environment variable → can’t find dependencies  
Just curious what is going on under the hood.

---

<div class="post-metadata">

### Author: ![aron.helser](https://discourse.kitware.com/user_avatar/discourse.kitware.com/aron.helser/32/149_2.png) [@aron.helser](https://discourse.kitware.com/u/aron.helser)
#### Post date: [July 14, 2022, 6:06pm UTC](https://discourse.kitware.com/t/how-does-cmake-find-all-the-dependencies-installed-by-cmb-superbuild/862/7 "2022-07-14T18:06:19Z")

</div>

Huh, I didn’t know that, interesting. What I believe is happening is that by adding to your PATH you are making those projects available as system projects - i.e. installed globally, like you might install a system Python or system Qt. This works, but makes it harder to swap versions for multiple builds.

I don’t think a Debug build will help with the OpenCascade plugin load. It looks like it’s missing a dependency. I think if you make a dummy project and dummy debug config to launch the app, it should tell you more. If not, you can look at the open cascade DLL with a dependency walker, like depends.exe, to see what it might be missing.
