Revision d523b8325857e4cd6f298ec9f356432676c81edb authored by Steven Johnson on 13 March 2021, 00:54:23 UTC, committed by GitHub on 13 March 2021, 00:54:23 UTC
(1) Both the 'deprecated' and new, non-deprecated variants existed back to at least LLVM10, and the deprecated variant was commented as deprecated at that point as well; the change in LLVM13 is that they are now annotated with LLVM_ATTRIBUTE_DEPRECATED so we get compiler warnings (and thus errors).

(2) The fixes are simply replicating what the old, deprecated methods did internally.
1 parent c3882a5
Raw File
AddCudaToTarget.cmake
function(add_cuda_to_target TARGET VISIBILITY)
    if (TARGET CUDA::cuda_driver AND TARGET CUDA::cudart)
        target_link_libraries(${TARGET} ${VISIBILITY} CUDA::cuda_driver CUDA::cudart)
        return()
    endif ()

    find_package(CUDAToolkit QUIET)
    if (TARGET CUDA::cuda_driver AND TARGET CUDA::cudart)
        target_link_libraries(${TARGET} ${VISIBILITY} CUDA::cuda_driver CUDA::cudart)
        return()
    endif ()

    # Find the package for the CUDA_TOOLKIT_ROOT_DIR hint.
    find_package(CUDA QUIET)
    if (NOT CUDA_FOUND)
        set(CUDA_TOOLKIT_ROOT_DIR)
    endif ()

    # Find the CUDA driver library by doing what the CUDAToolkit module from
    # CMake 3.17 does.
    find_library(CUDA_DRIVER_LIBRARY
                 NAMES cuda_driver cuda
                 HINTS ${CUDA_TOOLKIT_ROOT_DIR} ENV CUDA_PATH
                 PATH_SUFFIXES nvidia/current lib64 lib/x64 lib)
    if (NOT CUDA_DRIVER_LIBRARY)
        # Don't try any stub directories until we have exhausted all other search locations.
        find_library(CUDA_DRIVER_LIBRARY
                     NAMES cuda_driver cuda
                     HINTS ${CUDA_TOOLKIT_ROOT_DIR} ENV CUDA_PATH
                     PATH_SUFFIXES lib64/stubs lib/x64/stubs lib/stubs stubs)
    endif ()
    mark_as_advanced(CUDA_DRIVER_LIBRARY)

    if (NOT CUDA_DRIVER_LIBRARY)
        message(WARNING "CUDA driver library not found on system.")
        return()
    endif ()

    target_include_directories(${TARGET} ${VISIBILITY} ${CUDA_INCLUDE_DIRS})
    target_link_libraries(${TARGET} ${VISIBILITY} ${CUDA_LIBRARIES} ${CUDA_DRIVER_LIBRARY})
endfunction()
back to top