Skip to content

Commit 3cfaf3d

Browse files
committed
[libomptarget] Fix detection of CUDA stubs library
CUDA_LIBRARIES contains additional linker arguments since CMake 3.3 which breakes the current way of finding the stubs library. llvm-svn: 324879
1 parent 5379c6d commit 3cfaf3d

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,16 @@ find_library (
134134

135135
# There is a libcuda.so in lib64/stubs that can be used for linking.
136136
if (NOT LIBOMPTARGET_DEP_CUDA_DRIVER_LIBRARIES AND CUDA_FOUND)
137-
get_filename_component(CUDA_LIBDIR ${CUDA_LIBRARIES} DIRECTORY)
137+
# Since CMake 3.3 FindCUDA.cmake defaults to using static libraries. In this
138+
# case CUDA_LIBRARIES contains additional linker arguments which breaks
139+
# get_filename_component below. Fortunately, since that change the module
140+
# exports CUDA_cudart_static_LIBRARY which points to a single file in the
141+
# right directory.
142+
set(cuda_library ${CUDA_LIBRARIES})
143+
if (DEFINED CUDA_cudart_static_LIBRARY)
144+
set(cuda_library ${CUDA_cudart_static_LIBRARY})
145+
endif()
146+
get_filename_component(CUDA_LIBDIR ${cuda_library} DIRECTORY)
138147
find_library (
139148
LIBOMPTARGET_DEP_CUDA_DRIVER_LIBRARIES
140149
NAMES

0 commit comments

Comments
 (0)