Commit 765bf02d authored by Michael Kuron's avatar Michael Kuron Committed by GitHub

Properly detect CUDA libraries if multiple are available

parent 22d2ad90
Pipeline #3766 passed with stages
in 55 minutes and 7 seconds
......@@ -150,8 +150,8 @@ if (WITH_CUDA)
else()
set(CUDA_DIR "/usr/local/cuda")
endif()
find_library(CUDART_LIBRARY NAMES cudart PATHS ${CUDA_DIR}/lib64 ${CUDA_DIR}/lib /usr/local/nvidia/lib)
find_library(CUFFT_LIBRARY NAMES cufft PATHS ${CUDA_DIR}/lib64 ${CUDA_DIR}/lib /usr/local/nvidia/lib)
find_library(CUDART_LIBRARY NAMES cudart PATHS ${CUDA_DIR}/lib64 ${CUDA_DIR}/lib /usr/local/nvidia/lib NO_DEFAULT_PATH)
find_library(CUFFT_LIBRARY NAMES cufft PATHS ${CUDA_DIR}/lib64 ${CUDA_DIR}/lib /usr/local/nvidia/lib NO_DEFAULT_PATH)
list(APPEND LIBRARIES ${CUDART_LIBRARY})
list(APPEND LIBRARIES ${CUFFT_LIBRARY})
set(CUDA 1)
......@@ -176,7 +176,7 @@ if (WITH_CUDA)
target_link_libraries(${ARGV0} ${CUDA_LIBRARY} ${CUDART_LIBRARY})
endfunction()
function(CUDA_ADD_CUFFT_TO_TARGET target)
target_link_libraries(${target} "cufft")
target_link_libraries(${target} ${CUFFT_LIBRARY})
endfunction()
else()
find_package(HIP QUIET MODULE)
......@@ -203,6 +203,11 @@ if (WITH_CUDA)
if(CUDA_FOUND)
list(APPEND LIBRARIES ${CUDA_CUFFT_LIBRARIES})
list(APPEND LIBRARIES ${CUDA_LIBRARIES})
if(NOT CUDA_NVCC_EXECUTABLE STREQUAL "${CUDA_TOOLKIT_ROOT_DIR}/bin/nvcc")
get_filename_component(NVCC_EXECUTABLE_DIRNAME "${CUDA_NVCC_EXECUTABLE}" DIRECTORY)
get_filename_component(NVCC_EXECUTABLE_DIRNAME "${NVCC_EXECUTABLE_DIRNAME}" DIRECTORY)
message(WARNING "Your nvcc (${CUDA_NVCC_EXECUTABLE}) does not appear to match your CUDA libraries (in ${CUDA_TOOLKIT_ROOT_DIR}). While Espresso will still compile, you might get unexpected crashes. Please point CUDA_TOOLKIT_ROOT_DIR to your CUDA toolkit path, e.g. by adding -DCUDA_TOOLKIT_ROOT_DIR=${NVCC_EXECUTABLE_DIRNAME} to your cmake command.")
endif()
set(CUDA 1)
set(CUDA_NVCC_FLAGS_DEBUG "${CUDA_NVCC_FLAGS_DEBUG} -g -G")
......
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