Commit fff782f6 authored by Brad King's avatar Brad King

Tests: Simplify CUDA rpath on macOS

Use the `BUILD_RPATH` property and reference the CMake-computed location
of the runtime libraries.
parent ad4a68cc
...@@ -42,7 +42,6 @@ add_executable(CudaComplex main.cpp) ...@@ -42,7 +42,6 @@ add_executable(CudaComplex main.cpp)
target_link_libraries(CudaComplex PUBLIC CudaComplexMixedLib) target_link_libraries(CudaComplex PUBLIC CudaComplexMixedLib)
if(APPLE) if(APPLE)
# We need to add the default path to the driver (libcuda.dylib) as an rpath, so that # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime.
# the static cuda runtime can find it at runtime. set_property(TARGET CudaComplex PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES})
target_link_libraries(CudaComplex PRIVATE -Wl,-rpath,/usr/local/cuda/lib)
endif() endif()
...@@ -10,8 +10,8 @@ add_library(CudaMixedObjectLib OBJECT static.cu static.cpp) ...@@ -10,8 +10,8 @@ add_library(CudaMixedObjectLib OBJECT static.cu static.cpp)
add_executable(CudaObjectLibrary add_executable(CudaObjectLibrary
main.cpp main.cpp
$<TARGET_OBJECTS:CudaMixedObjectLib>) $<TARGET_OBJECTS:CudaMixedObjectLib>)
if(APPLE) if(APPLE)
# We need to add the default path to the driver (libcuda.dylib) as an rpath, so that # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime.
# the static cuda runtime can find it at runtime. set_property(TARGET CudaObjectLibrary PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES})
target_link_libraries(CudaObjectLibrary PRIVATE -Wl,-rpath,/usr/local/cuda/lib)
endif() endif()
...@@ -6,7 +6,6 @@ string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30") ...@@ -6,7 +6,6 @@ string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30")
add_executable(CudaWithC main.c cuda.cu) add_executable(CudaWithC main.c cuda.cu)
if(APPLE) if(APPLE)
# We need to add the default path to the driver (libcuda.dylib) as an rpath, so that # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime.
# the static cuda runtime can find it at runtime. set_property(TARGET CudaWithC PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES})
target_link_libraries(CudaWithC PRIVATE -Wl,-rpath,/usr/local/cuda/lib)
endif() endif()
...@@ -67,9 +67,8 @@ target_compile_definitions(CudaOnlyExportPTX PRIVATE ...@@ -67,9 +67,8 @@ target_compile_definitions(CudaOnlyExportPTX PRIVATE
"CONFIG_TYPE=gen_$<LOWER_CASE:$<CONFIG>>") "CONFIG_TYPE=gen_$<LOWER_CASE:$<CONFIG>>")
if(APPLE) if(APPLE)
# We need to add the default path to the driver (libcuda.dylib) as an rpath, so that # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime.
# the static cuda runtime can find it at runtime. set_property(TARGET CudaOnlyExportPTX PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES})
target_link_libraries(CudaOnlyExportPTX PRIVATE -Wl,-rpath,/usr/local/cuda/lib)
endif() endif()
#Verify that we can install object targets properly #Verify that we can install object targets properly
......
...@@ -46,7 +46,6 @@ add_executable(CudaOnlyResolveDeviceSymbols main.cu) ...@@ -46,7 +46,6 @@ add_executable(CudaOnlyResolveDeviceSymbols main.cu)
target_link_libraries(CudaOnlyResolveDeviceSymbols PRIVATE CUDAResolveDeviceLib) target_link_libraries(CudaOnlyResolveDeviceSymbols PRIVATE CUDAResolveDeviceLib)
if(APPLE) if(APPLE)
# We need to add the default path to the driver (libcuda.dylib) as an rpath, so that # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime.
# the static cuda runtime can find it at runtime. set_property(TARGET CudaOnlyResolveDeviceSymbols PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES})
target_link_libraries(CudaOnlyResolveDeviceSymbols PRIVATE -Wl,-rpath,/usr/local/cuda/lib)
endif() endif()
...@@ -39,8 +39,7 @@ if (CMAKE_GENERATOR MATCHES "^Visual Studio") ...@@ -39,8 +39,7 @@ if (CMAKE_GENERATOR MATCHES "^Visual Studio")
PROPERTIES CUDA_SEPARABLE_COMPILATION ON) PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
endif() endif()
if (APPLE) if(APPLE)
# We need to add the default path to the driver (libcuda.dylib) as an rpath, so that # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime.
# the static cuda runtime can find it at runtime. set_property(TARGET CudaOnlySeparateCompilation PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES})
target_link_libraries(CudaOnlySeparateCompilation PRIVATE -Wl,-rpath,/usr/local/cuda/lib)
endif() endif()
...@@ -36,8 +36,7 @@ target_compile_definitions(CudaOnlyWithDefs ...@@ -36,8 +36,7 @@ target_compile_definitions(CudaOnlyWithDefs
$<$<CONFIG:RELEASE>:$<BUILD_INTERFACE:${release_compile_defs}>> $<$<CONFIG:RELEASE>:$<BUILD_INTERFACE:${release_compile_defs}>>
) )
#we need to add an rpath for the cuda library so that everything if(APPLE)
#loads properly on the mac # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime.
if(CMAKE_SYSTEM_NAME MATCHES "Darwin") set_property(TARGET CudaOnlyWithDefs PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES})
set_target_properties(CudaOnlyWithDefs PROPERTIES LINK_FLAGS "-Wl,-rpath,${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES}")
endif() endif()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment