On Tuesday, October 21, 2014 06:52:58 PM Filipe Maia wrote: > CMake's FindCUDA.cmake module adds the rpath when run on Mac OSX > (from FindCUDA.cmake): > > 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. > if(CUDA_BUILD_EMULATION AND CUDA_CUDARTEMU_LIBRARY) > get_filename_component(_cuda_path_to_cudart "${CUDA_CUDARTEMU_LIBRARY}" > PATH) > else() > get_filename_component(_cuda_path_to_cudart "${CUDA_CUDART_LIBRARY}" > PATH) > endif() > if(_cuda_path_to_cudart) > list(APPEND CUDA_LIBRARIES -Wl,-rpath "-Wl,${_cuda_path_to_cudart}") > endif() > endif() > > This causes this problem for anything built with CUDA support > (e.g. CUDA_ADD_EXECUTABLE), by having one rpath from the CUDA module and > another one from cmake trying its automagic. > The rpath should probably be removed from the module.
Oh! It comes from Modules/FindCUDA.cmake. That does need fixed. Does the attached patch fix your problem? Clint > On Tue, Oct 14, 2014 at 9:56 PM, Clinton Stimpson <clin...@elemtech.com> > > wrote: > > On Tuesday, October 14, 2014 12:10:36 PM Peter Eastman wrote: > > > Hi Clint, > > > > > > In my case, it wasn't anything like that. I was only specifying > > > /usr/local/cuda/lib once. More specifically, my CMakeLists.txt > > > specified > > > > > > TARGET_LINK_LIBRARIES(${SHARED_TARGET} ${CUDA_LIBRARIES}) > > > > > > where CUDA_LIBRARIES is > > > > > > /usr/local/cuda/lib/libcudart.dylib-Wl,-rpath-Wl,/usr/local/cuda/lib > > > > Since CMake 2.8.12, CMake will automatically figure out the > > -Wl,-rpath-Wl,/usr/local/cuda/lib part for > > /usr/local/cuda/lib/libcudart.dylib. > > > > So, the duplicate comes from CMake adding it once, and you adding it once. > > > > You should be able to remove any -Wl,-rpath flags that you add manually > > with > > CMake 2.8.12 and newer, and let CMake take care of that for you. > > > > > This library also linked against another of my libraries, that also > > > > happened > > > > > to link against CUDA. So that's why it was getting referenced twice: > > once > > > > > directly, and once indirectly via a second library. > > > > > > In any case, it's not clear to me why CMake is calling > > > "install_name_tool > > > -delete_rpath". Everything works fine without doing that. And when you > > > > do > > > > > it, that breaks things. > > > > CMake calls "install_name_tool -delete_rpath" at install time to remove > > the > > build rpaths and add install rpaths as specified by the INSTALL_RPATH > > target > > property. > > > > For more details and examples: > > http://www.kitware.com/blog/home/post/510 > > http://www.cmake.org/Wiki/CMake_RPATH_handling > > > > Clint > > > > > Peter > > > > > > On Oct 14, 2014, at 11:06 AM, Clinton Stimpson <clin...@elemtech.com> > > > > wrote: > > > > Here's a simple way to reproduce from the command line: > > > > > > > > echo "void foo() {}" > lib.c > > > > gcc -dynamiclib -o libtest.dylib -Wl,-rpath,/usr/lib > > > > -Wl,-rpath,/usr/lib > > > > > > lib.c install_name_tool -delete_rpath /usr/lib libtest.dylib > > > > otool -L libtest.dylib > > > > > > > > # gives me the error: "load command 13 size zero (can't advance to > > > > other > > > > > > load commands)" > > > > > > > > At install time, CMake will call "install_name_tool -delete_rpath ... > > > > " as > > > > > > needed. > > > > > > > > I can't get into Apple's bug tracker. I don't know why. When I try > > > > to > > > > log > > > > in, it comes back with a generic error and it asks me to email them > > > > with > > > > > > details about the error. > > > > > > > > When I do the same on Linux, the GNU linker will consolidate the > > > > duplicate > > > > > > paths. > > > > > > > > Thanks! > > > > > > > > Clint > > > > -- > > Clinton Stimpson > > Elemental Technologies, Inc > > Computational Simulation Software, LLC > > www.csimsoft.com > > -- > > > > Powered by www.kitware.com > > > > Please keep messages on-topic and check the CMake FAQ at: > > http://www.cmake.org/Wiki/CMake_FAQ > > > > Kitware offers various services to support the CMake community. For more > > information on each offering, please visit: > > > > CMake Support: http://cmake.org/cmake/help/support.html > > CMake Consulting: http://cmake.org/cmake/help/consulting.html > > CMake Training Courses: http://cmake.org/cmake/help/training.html > > > > Visit other Kitware open-source projects at > > http://www.kitware.com/opensource/opensource.html > > > > Follow this link to subscribe/unsubscribe: > > http://public.kitware.com/mailman/listinfo/cmake
diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake index 2e2b21c..3dd975c 100644 --- a/Modules/FindCUDA.cmake +++ b/Modules/FindCUDA.cmake @@ -703,18 +703,6 @@ if(CUDA_BUILD_EMULATION AND CUDA_CUDARTEMU_LIBRARY) else() set(CUDA_LIBRARIES ${CUDA_CUDART_LIBRARY}) endif() -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. - if(CUDA_BUILD_EMULATION AND CUDA_CUDARTEMU_LIBRARY) - get_filename_component(_cuda_path_to_cudart "${CUDA_CUDARTEMU_LIBRARY}" PATH) - else() - get_filename_component(_cuda_path_to_cudart "${CUDA_CUDART_LIBRARY}" PATH) - endif() - 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.
-- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake