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