1 # Licensed to the Apache Software Foundation (ASF) under one
2 # or more contributor license agreements. See the NOTICE file
3 # distributed with this work for additional information
4 # regarding copyright ownership. The ASF licenses this file
5 # to you under the Apache License, Version 2.0 (the
6 # "License"); you may not use this file except in compliance
7 # with the License. You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing,
12 # software distributed under the License is distributed on an
13 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 # KIND, either express or implied. See the License for the
15 # specific language governing permissions and limitations
22 add_custom_target(arrow_cuda-all)
23 add_custom_target(arrow_cuda)
24 add_custom_target(arrow_cuda-benchmarks)
25 add_custom_target(arrow_cuda-tests)
26 add_dependencies(arrow_cuda-all arrow_cuda arrow_cuda-tests arrow_cuda-benchmarks)
28 if(DEFINED ENV{CUDA_HOME})
29 set(CUDA_TOOLKIT_ROOT_DIR "$ENV{CUDA_HOME}")
32 find_package(CUDA REQUIRED)
33 include_directories(SYSTEM ${CUDA_INCLUDE_DIRS})
35 set(ARROW_CUDA_SRCS cuda_arrow_ipc.cc cuda_context.cc cuda_internal.cc cuda_memory.cc)
37 set(ARROW_CUDA_SHARED_LINK_LIBS ${CUDA_CUDA_LIBRARY})
39 add_arrow_lib(arrow_cuda
49 ${ARROW_VERSION_SCRIPT_FLAGS} # Defined in cpp/arrow/CMakeLists.txt
52 ${ARROW_CUDA_SHARED_LINK_LIBS}
53 # Static arrow_cuda must also link against CUDA shared libs
55 ${ARROW_CUDA_SHARED_LINK_LIBS})
57 add_dependencies(arrow_cuda ${ARROW_CUDA_LIBRARIES})
59 foreach(LIB_TARGET ${ARROW_CUDA_LIBRARIES})
60 target_compile_definitions(${LIB_TARGET} PRIVATE ARROW_EXPORTING)
64 configure_file(cuda_version.h.in "${CMAKE_CURRENT_BINARY_DIR}/cuda_version.h" @ONLY)
66 install(FILES "${CMAKE_CURRENT_BINARY_DIR}/cuda_version.h"
67 DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/arrow/gpu")
69 arrow_install_all_headers("arrow/gpu")
71 if(ARROW_BUILD_SHARED)
72 set(ARROW_CUDA_LIBRARY arrow_cuda_shared)
74 set(ARROW_CUDA_LIBRARY arrow_cuda_static)
77 set(ARROW_CUDA_TEST_LINK_LIBS ${ARROW_CUDA_LIBRARY} ${ARROW_TEST_LINK_LIBS})
80 add_arrow_test(cuda_test STATIC_LINK_LIBS ${ARROW_CUDA_TEST_LINK_LIBS} NO_VALGRIND)
83 if(ARROW_BUILD_BENCHMARKS)
84 cuda_add_executable(arrow-cuda-benchmark cuda_benchmark.cc)
85 target_link_libraries(arrow-cuda-benchmark ${ARROW_CUDA_LIBRARY} GTest::gtest
86 ${ARROW_BENCHMARK_LINK_LIBS})
87 add_dependencies(arrow_cuda-benchmarks arrow-cuda-benchmark)