From aa495ad021a922bd3959f0eecb97d5e95c89e617 Mon Sep 17 00:00:00 2001 From: James Bigler Date: Thu, 28 Jan 2010 13:50:38 -0500 Subject: [PATCH] Add -rpath for cuda libraries on Apple. They use @rpath in the library link names. --- Modules/FindCUDA.cmake | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake index 2c60cfc45..6539057ba 100644 --- a/Modules/FindCUDA.cmake +++ b/Modules/FindCUDA.cmake @@ -546,6 +546,14 @@ endmacro() # CUDA_LIBRARIES find_library_local_first(CUDA_CUDART_LIBRARY cudart "\"cudart\" library") set(CUDA_LIBRARIES ${CUDA_CUDART_LIBRARY}) +if(APPLE) + # We need to add the path to cudart to the linker using rpath, since the + # library name for the cuda libraries is prepended with @rpath. + get_filename_component(_cuda_path_to_cudart "${CUDA_CUDART_LIBRARY}" PATH) + if(_cuda_path_to_cudart) + list(APPEND CUDA_LIBRARIES -Wl,-rpath "-Wl,${_cuda_path_to_cudart}") + endif() +endif() # 1.1 toolkit on linux doesn't appear to have a separate library on # some platforms.