|
10 | 10 | # Build a plugin for a CUDA machine if available. |
11 | 11 | # |
12 | 12 | ##===----------------------------------------------------------------------===## |
13 | | -if(LIBOMPTARGET_DEP_LIBELF_FOUND) |
14 | | - if(LIBOMPTARGET_DEP_CUDA_FOUND) |
15 | | - if(CMAKE_SYSTEM_PROCESSOR MATCHES "(x86_64)|(ppc64le)$" AND CMAKE_SYSTEM_NAME MATCHES "Linux") |
16 | | - |
17 | | - libomptarget_say("Building CUDA offloading plugin.") |
18 | | - |
19 | | - # Define the suffix for the runtime messaging dumps. |
20 | | - add_definitions(-DTARGET_NAME=CUDA) |
21 | | - |
22 | | - if(LIBOMPTARGET_CMAKE_BUILD_TYPE MATCHES debug) |
23 | | - add_definitions(-DCUDA_ERROR_REPORT) |
24 | | - endif() |
25 | | - |
26 | | - include_directories(${LIBOMPTARGET_DEP_CUDA_INCLUDE_DIRS}) |
27 | | - include_directories(${LIBOMPTARGET_DEP_LIBELF_INCLUDE_DIRS}) |
28 | | - |
29 | | - add_library(omptarget.rtl.cuda SHARED src/rtl.cpp) |
30 | | - |
31 | | - # Install plugin under the lib destination folder. |
32 | | - install(TARGETS omptarget.rtl.cuda LIBRARY DESTINATION lib${OPENMP_LIBDIR_SUFFIX}) |
33 | | - |
34 | | - target_link_libraries(omptarget.rtl.cuda |
35 | | - ${LIBOMPTARGET_DEP_CUDA_LIBRARIES} |
36 | | - cuda |
37 | | - ${LIBOMPTARGET_DEP_LIBELF_LIBRARIES} |
38 | | - "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/../exports") |
39 | | - |
40 | | - # Report to the parent scope that we are building a plugin for CUDA. |
41 | | - set(LIBOMPTARGET_SYSTEM_TARGETS "${LIBOMPTARGET_SYSTEM_TARGETS} nvptx64-nvidia-cuda" PARENT_SCOPE) |
42 | | - else() |
43 | | - libomptarget_say("Not building CUDA offloading plugin: only support CUDA in Linux x86_64 or ppc64le hosts.") |
44 | | - endif() |
45 | | - else() |
46 | | - libomptarget_say("Not building CUDA offloading plugin: CUDA not found in system.") |
47 | | - endif() |
48 | | -else(LIBOMPTARGET_DEP_LIBELF_FOUND) |
| 13 | +if (NOT(CMAKE_SYSTEM_PROCESSOR MATCHES "(x86_64)|(ppc64le)$" AND CMAKE_SYSTEM_NAME MATCHES "Linux")) |
| 14 | + libomptarget_say("Not building CUDA offloading plugin: only support CUDA in Linux x86_64 or ppc64le hosts.") |
| 15 | + return() |
| 16 | +elseif (NOT LIBOMPTARGET_DEP_LIBELF_FOUND) |
49 | 17 | libomptarget_say("Not building CUDA offloading plugin: libelf dependency not found.") |
50 | | -endif(LIBOMPTARGET_DEP_LIBELF_FOUND) |
| 18 | + return() |
| 19 | +elseif(NOT LIBOMPTARGET_DEP_CUDA_FOUND) |
| 20 | + libomptarget_say("Not building CUDA offloading plugin: CUDA not found in system.") |
| 21 | + return() |
| 22 | +elseif(NOT LIBOMPTARGET_DEP_CUDA_DRIVER_FOUND) |
| 23 | + libomptarget_say("Not building CUDA offloading plugin: CUDA Driver API not found in system.") |
| 24 | + return() |
| 25 | +endif() |
| 26 | + |
| 27 | +libomptarget_say("Building CUDA offloading plugin.") |
| 28 | + |
| 29 | +# Define the suffix for the runtime messaging dumps. |
| 30 | +add_definitions(-DTARGET_NAME=CUDA) |
| 31 | + |
| 32 | +if(LIBOMPTARGET_CMAKE_BUILD_TYPE MATCHES debug) |
| 33 | + add_definitions(-DCUDA_ERROR_REPORT) |
| 34 | +endif() |
| 35 | + |
| 36 | +include_directories(${LIBOMPTARGET_DEP_CUDA_INCLUDE_DIRS}) |
| 37 | +include_directories(${LIBOMPTARGET_DEP_LIBELF_INCLUDE_DIRS}) |
| 38 | + |
| 39 | +add_library(omptarget.rtl.cuda SHARED src/rtl.cpp) |
| 40 | + |
| 41 | +# Install plugin under the lib destination folder. |
| 42 | +install(TARGETS omptarget.rtl.cuda LIBRARY DESTINATION lib${OPENMP_LIBDIR_SUFFIX}) |
| 43 | + |
| 44 | +target_link_libraries(omptarget.rtl.cuda |
| 45 | + ${LIBOMPTARGET_DEP_CUDA_DRIVER_LIBRARIES} |
| 46 | + ${LIBOMPTARGET_DEP_LIBELF_LIBRARIES} |
| 47 | + "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/../exports") |
| 48 | + |
| 49 | +# Report to the parent scope that we are building a plugin for CUDA. |
| 50 | +set(LIBOMPTARGET_SYSTEM_TARGETS "${LIBOMPTARGET_SYSTEM_TARGETS} nvptx64-nvidia-cuda" PARENT_SCOPE) |
0 commit comments