Add prefix right before "-Wl,rpath,PATH"

Hi all,
I have a cmake script which works fine with both GNU and Intel compilers. Now I intend to compile my code with nvcc to generate CUDA compatible code and surprisingly nvcc compiler font-end does not understand “-Wl,rpath,PATH” which is added by cmake to the link libraries. I have tried and I see that when I add “-Xcompiler” right before this to become “-Xcompiler -Wl,rpath,PATH” then nvcc links the project correctly. Does anybody know how can I enhance my cmake script, so cmake will generate Makefile that automatically added “-Xcompiler” right before “-Wl,rpath,PATH”?
Regards,
Dan

@robert.maynard Do you know if the behavior Danesh describes is expected?

1 Like

What version of nvcc and CMake are you using?

nvcc 10.2+ with CMake 3.17+ will automatically pass the -forward-unknown-to-host-compiler flag when compiling or linking with nvcc. That will allow automatic propagation of flags like -Wl,rpath to the host compiler.

1 Like

Hi Rob and Craig,
Thanks for your answers. I am using nvcc 12.4.99 and cmake 3.27.7. My intention is to just add -Xcompiler as a prefix to -Wl,rpath because when I do manually the code links correctly. Or, the other alternative is to setup cmake not to add -Wl,rpath it also works. Can you please advice?
Regards,
Dan

@robert.maynard, @craig.scott
May I ask my question like this? Is there anyway to configure CMake script so no “-Wl,rpath, PATH” will be added in the linking command at all? Then it will solve my problem. Now I have to do it manually and things work without problem.
Regards,
Danesh

Does CMAKE_SKIP_RPATH give you what you are looking for?

1 Like

Oh yes that did the job! I added this line in my cmake script and no rpath is now added:

set(CMAKE_SKIP_RPATH TRUE)

Thanks a lot @craig.scott.