# CUDA dependency in sub project

**URL:** https://discourse.cmake.org/t/cuda-dependency-in-sub-project/2144
**Category:** Usage
**Tags:** lang:cuda
**Created:** [November 9, 2020, 3:40pm UTC](https://discourse.cmake.org/t/cuda-dependency-in-sub-project/2144 "2020-11-09T15:40:47Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Morteza\_Kianian](https://discourse.cmake.org/user_avatar/discourse.cmake.org/morteza_kianian/32/915_2.png) [@Morteza\_Kianian](https://discourse.cmake.org/u/Morteza_Kianian)
#### Post date: [November 9, 2020, 3:40pm UTC](https://discourse.cmake.org/t/cuda-dependency-in-sub-project/2144/1 "2020-11-09T15:40:47Z")

</div>

I have a project which is a library that depends on a couple of other libraries (dependencies). The code and `CMakeLists.txt` for the dependencies are in sub-directories within a directory called `depend` which contains a `CMakeLists.txt` that adds the sub projects by `add_subdirectory()` command. One of the dependencies requires `CUDA` libraries. I can build this sub-project separately without any issues however When adding this sub-project into the main one I get the error `CUDA_ARCHITECTURES is empty for target` but the other targets for which `cmake` complains about don’t require `CUDA`. How should I fix this?

---

<div class="post-metadata">

### Author: ![robert.maynard](https://discourse.cmake.org/user_avatar/discourse.cmake.org/robert.maynard/32/4_2.png) [@robert.maynard](https://discourse.cmake.org/u/robert.maynard)
#### Post date: [November 10, 2020, 8:09pm UTC](https://discourse.cmake.org/t/cuda-dependency-in-sub-project/2144/2 "2020-11-10T20:09:33Z")

</div>

Currently you will need to hoist the requirement of `CUDA` as an enabled language to have the same visibility of all targets. Generally this means that your root CMakeLists needs to optionally enable the CUDA language ( `enable_language(CUDA)` ) when you know you will include that dependency.
