CUDA dependency in sub project

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?

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.