FindCUDA: CUDA_LIBRARIES doesn't contain raw -pthread

If a person tried to pass `CUDA_LIBRARIES` to nvcc compiler it could
fail as it might have `-pthread` which nvcc doesn't support. Instead
we now use the `Threads::Threads` so that nvcc gets the correct
`-Xcompiler -pthread` flag.
This commit is contained in:
Robert Maynard
2019-11-11 11:49:52 -05:00
parent 74569996e8
commit 46371132b3

View File

@@ -924,7 +924,7 @@ set(CUDA_LIBRARIES)
if(CUDA_BUILD_EMULATION AND CUDA_CUDARTEMU_LIBRARY)
list(APPEND CUDA_LIBRARIES ${CUDA_CUDARTEMU_LIBRARY})
elseif(CUDA_USE_STATIC_CUDA_RUNTIME AND CUDA_cudart_static_LIBRARY)
list(APPEND CUDA_LIBRARIES ${CUDA_cudart_static_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS})
list(APPEND CUDA_LIBRARIES ${CUDA_cudart_static_LIBRARY} Threads::Threads ${CMAKE_DL_LIBS})
if (CUDA_rt_LIBRARY)
list(APPEND CUDA_LIBRARIES ${CUDA_rt_LIBRARY})
endif()