|
| 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 |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 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 |
| 16 | +# under the License. |
| 17 | + |
| 18 | +function(ADD_ARROW_CUDA_TEST REL_TEST_NAME) |
| 19 | + set(options) |
| 20 | + set(single_value_args) |
| 21 | + set(multi_value_args STATIC_LINK_LIBS) |
| 22 | + cmake_parse_arguments(ARG "${options}" "${one_value_args}" "${multi_value_args}" ${ARGN}) |
| 23 | + if(ARG_UNPARSED_ARGUMENTS) |
| 24 | + message(SEND_ERROR "Error: unrecognized arguments: ${ARG_UNPARSED_ARGUMENTS}") |
| 25 | + endif() |
| 26 | + |
| 27 | + if(NO_TESTS OR NOT ARROW_BUILD_STATIC) |
| 28 | + return() |
| 29 | + endif() |
| 30 | + get_filename_component(TEST_NAME ${REL_TEST_NAME} NAME_WE) |
| 31 | + |
| 32 | + if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${REL_TEST_NAME}.cc) |
| 33 | + # This test has a corresponding .cc file, set it up as an executable. |
| 34 | + set(TEST_PATH "${EXECUTABLE_OUTPUT_PATH}/${TEST_NAME}") |
| 35 | + cuda_add_executable(${TEST_NAME} "${REL_TEST_NAME}.cc") |
| 36 | + |
| 37 | + if (ARG_STATIC_LINK_LIBS) |
| 38 | + # Customize link libraries |
| 39 | + target_link_libraries(${TEST_NAME} ${ARG_STATIC_LINK_LIBS}) |
| 40 | + else() |
| 41 | + target_link_libraries(${TEST_NAME} ${ARROW_TEST_LINK_LIBS}) |
| 42 | + endif() |
| 43 | + add_dependencies(unittest ${TEST_NAME}) |
| 44 | + else() |
| 45 | + # No executable, just invoke the test (probably a script) directly. |
| 46 | + set(TEST_PATH ${CMAKE_CURRENT_SOURCE_DIR}/${REL_TEST_NAME}) |
| 47 | + endif() |
| 48 | + |
| 49 | + if (ARROW_TEST_MEMCHECK) |
| 50 | + SET_PROPERTY(TARGET ${TEST_NAME} |
| 51 | + APPEND_STRING PROPERTY |
| 52 | + COMPILE_FLAGS " -DARROW_VALGRIND") |
| 53 | + add_test(${TEST_NAME} |
| 54 | + bash -c "cd ${EXECUTABLE_OUTPUT_PATH}; valgrind --tool=memcheck --leak-check=full --leak-check-heuristics=stdstring --error-exitcode=1 ${TEST_PATH}") |
| 55 | + elseif(MSVC) |
| 56 | + add_test(${TEST_NAME} ${TEST_PATH}) |
| 57 | + else() |
| 58 | + add_test(${TEST_NAME} |
| 59 | + ${BUILD_SUPPORT_DIR}/run-test.sh ${CMAKE_BINARY_DIR} test ${TEST_PATH}) |
| 60 | + endif() |
| 61 | + set_tests_properties(${TEST_NAME} PROPERTIES LABELS "unittest") |
| 62 | +endfunction() |
| 63 | + |
| 64 | +####################################### |
| 65 | +# arrow_gpu |
| 66 | +####################################### |
| 67 | + |
| 68 | +if (DEFINED ENV{CUDA_HOME}) |
| 69 | + set(CUDA_TOOLKIT_ROOT_DIR "$ENV{CUDA_HOME}") |
| 70 | +endif() |
| 71 | + |
| 72 | +find_package(CUDA REQUIRED) |
| 73 | +include_directories(SYSTEM ${CUDA_INCLUDE_DIRS}) |
| 74 | + |
| 75 | +set(ARROW_GPU_SRCS |
| 76 | + cuda_memory.cc |
| 77 | +) |
| 78 | + |
| 79 | +set(ARROW_GPU_SHARED_LINK_LIBS |
| 80 | + arrow_shared |
| 81 | +) |
| 82 | + |
| 83 | +cuda_add_library(arrow_gpu SHARED |
| 84 | + ${ARROW_GPU_SRCS} |
| 85 | +) |
| 86 | + |
| 87 | +install(FILES |
| 88 | + cuda_common.h |
| 89 | + cuda_memory.h |
| 90 | + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/arrow/gpu") |
| 91 | + |
| 92 | +# pkg-config support |
| 93 | +configure_file(arrow-gpu.pc.in |
| 94 | + "${CMAKE_CURRENT_BINARY_DIR}/arrow-gpu.pc" |
| 95 | + @ONLY) |
| 96 | +install( |
| 97 | + FILES "${CMAKE_CURRENT_BINARY_DIR}/arrow-gpu.pc" |
| 98 | + DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig/") |
| 99 | + |
| 100 | +if (ARROW_BUILD_TESTS) |
| 101 | + set(ARROW_GPU_TEST_LINK_LIBS |
| 102 | + ${ARROW_TEST_LINK_LIBS} |
| 103 | + arrow_gpu) |
| 104 | + ADD_ARROW_CUDA_TEST(cuda-test |
| 105 | + STATIC_LINK_LIBS ${ARROW_GPU_TEST_LINK_LIBS}) |
| 106 | +endif() |
0 commit comments