|
| 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 | +if(ArrowAlt_FOUND) |
| 19 | + return() |
| 20 | +endif() |
| 21 | + |
| 22 | +set(find_package_args) |
| 23 | +if(ArrowAlt_FIND_VERSION) |
| 24 | + list(APPEND find_package_args ${ArrowAlt_FIND_VERSION}) |
| 25 | +endif() |
| 26 | +if(ArrowAlt_FIND_QUIETLY) |
| 27 | + list(APPEND find_package_args QUIET) |
| 28 | +endif() |
| 29 | +find_package(Arrow ${find_package_args}) |
| 30 | +if(Arrow_FOUND) |
| 31 | + set(ArrowAlt_FOUND TRUE) |
| 32 | + set(ArrowAlt_VERSION ${ARROW_VERSION}) |
| 33 | + return() |
| 34 | +endif() |
| 35 | + |
| 36 | +if(ARROW_ROOT) |
| 37 | + find_library(ARROW_STATIC_LIB |
| 38 | + NAMES arrow |
| 39 | + PATHS ${ARROW_ROOT} |
| 40 | + NO_DEFAULT_PATH |
| 41 | + PATH_SUFFIXES ${ICEBERG_LIBRARY_PATH_SUFFIXES}) |
| 42 | + find_path(ARROW_INCLUDE_DIR |
| 43 | + NAMES arrow/api.h |
| 44 | + PATHS ${ARROW_ROOT} |
| 45 | + NO_DEFAULT_PATH |
| 46 | + PATH_SUFFIXES ${ICEBERG_LIBRARY_PATH_SUFFIXES}) |
| 47 | +else() |
| 48 | + find_library(ARROW_STATIC_LIB |
| 49 | + NAMES arrow |
| 50 | + PATH_SUFFIXES ${ARROW_LIBRARY_PATH_SUFFIXES}) |
| 51 | + find_path(ARROW_INCLUDE_DIR |
| 52 | + NAMES arrow/api.h |
| 53 | + PATH_SUFFIXES ${ICEBERG_INCLUDE_PATH_SUFFIXES}) |
| 54 | +endif() |
| 55 | +if(ARROW_INCLUDE_DIR) |
| 56 | + file(READ "${ARROW_INCLUDE_DIR}/arrow/util/config.h" ARROW_CONFIG_HH_CONTENT) |
| 57 | + string(REGEX MATCH "#define ARROW_VERSION_STRING \"[0-9.]+\"" ARROW_VERSION_DEFINITION |
| 58 | + "${ARROW_CONFIG_HH_CONTENT}") |
| 59 | + string(REGEX MATCH "[0-9.]+" ARROW_VERSION "${ARROW_VERSION_DEFINITION}") |
| 60 | +endif() |
| 61 | + |
| 62 | +find_package_handle_standard_args( |
| 63 | + ArrowAlt |
| 64 | + REQUIRED_VARS ARROW_STATIC_LIB ARROW_INCLUDE_DIR |
| 65 | + VERSION_VAR ARROW_VERSION) |
| 66 | + |
| 67 | +if(ArrowAlt_FOUND) |
| 68 | + if(NOT TARGET Arrow::arrow_static) |
| 69 | + add_library(Arrow::arrow_static STATIC IMPORTED) |
| 70 | + set_target_properties(Arrow::arrow_static |
| 71 | + PROPERTIES IMPORTED_LOCATION "${ARROW_STATIC_LIB}" |
| 72 | + INTERFACE_INCLUDE_DIRECTORIES "${ARROW_INCLUDE_DIR}") |
| 73 | + endif() |
| 74 | + set(ArrowAlt_VERSION ${ARROW_VERSION}) |
| 75 | +endif() |
0 commit comments