FindCUDAToolkit: driver and runtime libraries missing some dependencies
This issue is similar to #23835 (closed), but wider. It's possible that I should have reported them all together, so sorry about that.
Anyway, consider the two targets CUDA::cuda_driver
and CUDA::runtime
. On a typical GNU/Linux system (e.g. SLES 15 SP1), they have no value for their INTERFACE_LINK_LIBRARIES
property. However, when using ldd
on the respective actual libraries (.so
files), we find:
$ ldd /usr/lib/libcuda.so
linux-gate.so.1 (0xf76e3000)
libm.so.6 => /lib/libm.so.6 (0xf5cf6000)
libc.so.6 => /lib/libc.so.6 (0xf5b1b000)
libdl.so.2 => /lib/libdl.so.2 (0xf5b16000)
libpthread.so.0 => /lib/libpthread.so.0 (0xf5af7000)
librt.so.1 => /lib/librt.so.1 (0xf5aed000)
/lib/ld-linux.so.2 (0xf76e4000)
$
$ ldd /usr/local/cuda/lib64/libcudart.so
linux-vdso.so.1 (0x00007ffc82d1e000)
libc.so.6 => /lib64/libc.so.6 (0x00007f69d497e000)
/lib64/ld-linux-x86-64.so.2 (0x00007f69d4fc7000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007f69d477a000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f69d455c000)
librt.so.1 => /lib64/librt.so.1 (0x00007f69d4354000)
Now, I don't know about linux-vdso
and the ld-linux
and libc
dependencies; but it looks like these targets should have somerthing like:
find_package(Threads REQUIRED)
foreach (tgt cudart cuda_driver)
target_link_libraries(${tgt} INTERFACE Threads::Threads ${CMAKE_DL_LIBS})
if(UNIX AND NOT APPLE)
target_link_libraries(${tgt} INTERFACE rt) # Not 100% sure this is necessary
endif()
endforeach()
target_link_libraries(cuda_driver INTERFACE m)
i.e. the dependencies should be marked. Am I wrong?
Edited by Eyal Rozenberg