Inclusion of CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES

Hi,

I have a simple project relaying on some cuda libraries, using a slightly older cmake (3.25). I have found that the inclusion of the CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES in the linker command is only done by CMake when at least one of the files in the target has a .cu extension. This seems a bit strange, since it’s possible to have a project using CUDA without a .cu file. I haven’t been able to find any entry in the documentation that explains why/how this is the case.

How does the inclusion work and is it a better way of doing it than just adding the value of the variable to the target link directories? Thanks.

Cc: @robert.maynard

CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES represents the directories implicitly add by the CUDA compiler when linking. Therefore it is only used by targets that have CUDA sources or link to a target that has CUDA sources.

since it’s possible to have a project using CUDA without a .cu file.

I expect you mean use libraries provided by the CUDA Toolkit. In theses cases you should be using the targets provided by find_package(CUDAToolkit) ( https://cmake.org/cmake/help/v3.25/module/FindCUDAToolkit.html ). CMake conceptually models the CUDA programming language separately from the CUDA Toolkit