Cannot add library to CUDA device code linking step if target is a static library
I understand that normally linking libraries when the target is a static library does not make sense, and target_link_libraries
simply records these dependencies in the upper project (if that is a shared library/executable). See also #16931 (closed) .
However, this does not play well in the situation where the target is a CUDA static library and I have set CUDA_RESOLVE_DEVICE_SYMBOLS
. There are instances where you need to add a library when linking the device code: for example, you need this step when you use the cuFFT library with callbacks on Linux (see https://docs.nvidia.com/pdf/CUFFT_Library.pdf).
The only workaround I found so far is to manipulate directly the variable CMAKE_CUDA_DEVICE_LINK_LIBRARY
and append my libraries at the end, which is arguably a dirty hack.