|  | 
|  | 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 | +# - Find GANDIVA (gandiva/client.h, libgandiva.a, libgandiva.so) | 
|  | 19 | +# This module defines | 
|  | 20 | +#  GANDIVA_INCLUDE_DIR, directory containing headers | 
|  | 21 | +#  GANDIVA_LIBS, directory containing gandiva libraries | 
|  | 22 | +#  GANDIVA_STATIC_LIB, path to libgandiva.a | 
|  | 23 | +#  GANDIVA_SHARED_LIB, path to libgandiva's shared library | 
|  | 24 | +#  GANDIVA_SHARED_IMP_LIB, path to libgandiva's import library (MSVC only) | 
|  | 25 | +#  GANDIVA_FOUND, whether gandiva has been found | 
|  | 26 | + | 
|  | 27 | +include(FindPkgConfig) | 
|  | 28 | + | 
|  | 29 | +if ("$ENV{ARROW_HOME}" STREQUAL "") | 
|  | 30 | +  pkg_check_modules(GANDIVA gandiva) | 
|  | 31 | +  if (GANDIVA_FOUND) | 
|  | 32 | +    pkg_get_variable(GANDIVA_SO_VERSION gandiva so_version) | 
|  | 33 | +    set(GANDIVA_ABI_VERSION ${GANDIVA_SO_VERSION}) | 
|  | 34 | +    message(STATUS "Gandiva SO and ABI version: ${GANDIVA_SO_VERSION}") | 
|  | 35 | +    pkg_get_variable(GANDIVA_FULL_SO_VERSION gandiva full_so_version) | 
|  | 36 | +    message(STATUS "Gandiva full SO version: ${GANDIVA_FULL_SO_VERSION}") | 
|  | 37 | +    set(GANDIVA_INCLUDE_DIR ${GANDIVA_INCLUDE_DIRS}) | 
|  | 38 | +    set(GANDIVA_LIBS ${GANDIVA_LIBRARY_DIRS}) | 
|  | 39 | +    set(GANDIVA_SEARCH_LIB_PATH ${GANDIVA_LIBRARY_DIRS}) | 
|  | 40 | +  endif() | 
|  | 41 | +else() | 
|  | 42 | +  set(GANDIVA_HOME "$ENV{ARROW_HOME}") | 
|  | 43 | + | 
|  | 44 | +  set(GANDIVA_SEARCH_HEADER_PATHS | 
|  | 45 | +    ${GANDIVA_HOME}/include | 
|  | 46 | +    ) | 
|  | 47 | + | 
|  | 48 | +  set(GANDIVA_SEARCH_LIB_PATH | 
|  | 49 | +    ${GANDIVA_HOME}/lib | 
|  | 50 | +    ) | 
|  | 51 | + | 
|  | 52 | +  find_path(GANDIVA_INCLUDE_DIR gandiva/expression_registry.h PATHS | 
|  | 53 | +    ${GANDIVA_SEARCH_HEADER_PATHS} | 
|  | 54 | +    # make sure we don't accidentally pick up a different version | 
|  | 55 | +    NO_DEFAULT_PATH | 
|  | 56 | +    ) | 
|  | 57 | +endif() | 
|  | 58 | + | 
|  | 59 | +find_library(GANDIVA_LIB_PATH NAMES gandiva | 
|  | 60 | +  PATHS | 
|  | 61 | +  ${GANDIVA_SEARCH_LIB_PATH} | 
|  | 62 | +  NO_DEFAULT_PATH) | 
|  | 63 | +get_filename_component(GANDIVA_LIBS ${GANDIVA_LIB_PATH} DIRECTORY) | 
|  | 64 | + | 
|  | 65 | +if (GANDIVA_INCLUDE_DIR AND GANDIVA_LIBS) | 
|  | 66 | +  set(GANDIVA_FOUND TRUE) | 
|  | 67 | +  set(GANDIVA_LIB_NAME gandiva) | 
|  | 68 | + | 
|  | 69 | +  set(GANDIVA_STATIC_LIB ${GANDIVA_LIBS}/lib${GANDIVA_LIB_NAME}.a) | 
|  | 70 | + | 
|  | 71 | +  set(GANDIVA_SHARED_LIB ${GANDIVA_LIBS}/lib${GANDIVA_LIB_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}) | 
|  | 72 | +endif() | 
|  | 73 | + | 
|  | 74 | +if (GANDIVA_FOUND) | 
|  | 75 | +  if (NOT Gandiva_FIND_QUIETLY) | 
|  | 76 | +    message(STATUS "Found the Gandiva core library: ${GANDIVA_LIB_PATH}") | 
|  | 77 | +  endif () | 
|  | 78 | +else () | 
|  | 79 | +  if (NOT Gandiva_FIND_QUIETLY) | 
|  | 80 | +    set(GANDIVA_ERR_MSG "Could not find the Gandiva library. Looked for headers") | 
|  | 81 | +    set(GANDIVA_ERR_MSG "${GANDIVA_ERR_MSG} in ${GANDIVA_SEARCH_HEADER_PATHS}, and for libs") | 
|  | 82 | +    set(GANDIVA_ERR_MSG "${GANDIVA_ERR_MSG} in ${GANDIVA_SEARCH_LIB_PATH}") | 
|  | 83 | +    if (Gandiva_FIND_REQUIRED) | 
|  | 84 | +      message(FATAL_ERROR "${GANDIVA_ERR_MSG}") | 
|  | 85 | +    else (Gandiva_FIND_REQUIRED) | 
|  | 86 | +      message(STATUS "${GANDIVA_ERR_MSG}") | 
|  | 87 | +    endif (Gandiva_FIND_REQUIRED) | 
|  | 88 | +  endif () | 
|  | 89 | +  set(GANDIVA_FOUND FALSE) | 
|  | 90 | +endif () | 
|  | 91 | + | 
|  | 92 | +mark_as_advanced( | 
|  | 93 | +  GANDIVA_INCLUDE_DIR | 
|  | 94 | +  GANDIVA_STATIC_LIB | 
|  | 95 | +  GANDIVA_SHARED_LIB | 
|  | 96 | +) | 
0 commit comments