CUDA: target_link_options setting not used in device link phase
This issue was encountered when trying to work around #22390 ; but it is independent of it.
I'm using CMake 3.21.0-rc2 on Ubuntu Bionic (on a Travis CI machine), to build a CUDA target named execution_control
which has separable compilation turned on. For some reason which does not matter at the moment, I am running:
target_link_options(execution_control PRIVATE "-L/usr/lib/x86_64-linux-gnu")
Yes, I know this is very ugly, non-portable and not a good thing to do, but putting that aside - this is a link option. Once I call target_link_options()
, I should see this on the command-line for device linking. But - I don't:
/usr/local/cuda-10.2/bin/nvcc -forward-unknown-to-host-compiler -Xcompiler -Wall -O3 -DNDEBUG --generate-code=arch=compute_52,code=[compute_52,sm_52] --generate-code=arch=compute_53,code=[compute_53,sm_53] --generate-code=arch=compute_60,code=[compute_60,sm_60] --generate-code=arch=compute_61,code=[compute_61,sm_61] --generate-code=arch=compute_62,code=[compute_62,sm_62] --generate-code=arch=compute_70,code=[compute_70,sm_70] --generate-code=arch=compute_72,code=[compute_72,sm_72] --generate-code=arch=compute_75,code=[compute_75,sm_75] -Xcompiler=-fPIC -Wno-deprecated-gpu-targets -shared -dlink CMakeFiles/execution_control.dir/by_runtime_api_module/execution_control.cu.o -o CMakeFiles/execution_control.dir/cmake_device_link.o -lcudadevrt -lcudart_static -lrt -lpthread -ldl
Assuming I have not misunderstood the semantics of target_link_options()
, this seems like a bug.