1 # Create the library and add the default arguments.
2 add_target_library(omptarget.rtl.cuda CUDA)
4 target_sources(omptarget.rtl.cuda PRIVATE src/rtl.cpp)
6 find_package(CUDAToolkit QUIET)
7 if(CUDAToolkit_FOUND AND NOT "cuda" IN_LIST LIBOMPTARGET_DLOPEN_PLUGINS)
8 message(STATUS "Building CUDA plugin linked against libcuda")
9 target_link_libraries(omptarget.rtl.cuda PRIVATE CUDA::cuda_driver)
11 message(STATUS "Building CUDA plugin for dlopened libcuda")
12 target_include_directories(omptarget.rtl.cuda PRIVATE dynamic_cuda)
13 target_sources(omptarget.rtl.cuda PRIVATE dynamic_cuda/cuda.cpp)
16 # Configure testing for the CUDA plugin. We will build tests if we could a
17 # functional NVIDIA GPU on the system, or if manually specifies by the user.
18 option(LIBOMPTARGET_FORCE_NVIDIA_TESTS "Build NVIDIA libomptarget tests" OFF)
19 if (LIBOMPTARGET_FOUND_NVIDIA_GPU OR LIBOMPTARGET_FORCE_NVIDIA_TESTS)
20 message(STATUS "Enable tests using CUDA plugin")
21 set(LIBOMPTARGET_SYSTEM_TARGETS
22 "${LIBOMPTARGET_SYSTEM_TARGETS} nvptx64-nvidia-cuda nvptx64-nvidia-cuda-LTO" PARENT_SCOPE)
23 list(APPEND LIBOMPTARGET_TESTED_PLUGINS "omptarget.rtl.cuda")
24 set(LIBOMPTARGET_TESTED_PLUGINS "${LIBOMPTARGET_TESTED_PLUGINS}" PARENT_SCOPE)
26 message(STATUS "Not generating NVIDIA tests, no supported devices detected."
27 " Use 'LIBOMPTARGET_FORCE_NVIDIA_TESTS' to override.")