Skip to content

Commit 5452bda

Browse files
authored
Add arrow dependency (#47)
Add arrow dependency
1 parent c6e4af9 commit 5452bda

2 files changed

Lines changed: 127 additions & 0 deletions

File tree

cmake/FindArrow.cmake

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
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 ARROW (arrow/api.h, libarrow.a, libarrow.so)
19+
# This module defines
20+
# ARROW_INCLUDE_DIR, directory containing headers
21+
# ARROW_STATIC_LIB, path to libarrow.a
22+
# ARROW_SHARED_LIB, path to libarrow's shared library
23+
# ARROW_FOUND, whether arrow has been found
24+
25+
if (DEFINED ENV{ARROW_HOME})
26+
set(ARROW_HOME "$ENV{ARROW_HOME}")
27+
endif()
28+
29+
if ("${ARROW_HOME}" STREQUAL "")
30+
# PARQUET-955. If the user has set $ARROW_HOME in the environment, we respect
31+
# this, otherwise try to locate the pkgconfig in the system environment
32+
if (ARROW_FOUND)
33+
# We found the pkgconfig
34+
set(ARROW_INCLUDE_DIR ${ARROW_INCLUDE_DIRS})
35+
36+
if (COMMAND pkg_get_variable)
37+
pkg_get_variable(ARROW_ABI_VERSION arrow abi_version)
38+
else()
39+
set(ARROW_ABI_VERSION "")
40+
endif()
41+
if (ARROW_ABI_VERSION STREQUAL "")
42+
set(ARROW_SHARED_LIB_SUFFIX "")
43+
else()
44+
set(ARROW_SHARED_LIB_SUFFIX ".${ARROW_ABI_VERSION}")
45+
endif()
46+
47+
set(ARROW_LIB_NAME ${CMAKE_SHARED_LIBRARY_PREFIX}arrow)
48+
49+
if (APPLE)
50+
set(ARROW_SHARED_LIB ${ARROW_LIBDIR}/${ARROW_LIB_NAME}${ARROW_SHARED_LIB_SUFFIX}${CMAKE_SHARED_LIBRARY_SUFFIX})
51+
else()
52+
set(ARROW_SHARED_LIB ${ARROW_LIBDIR}/${ARROW_LIB_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}${ARROW_SHARED_LIB_SUFFIX})
53+
endif()
54+
set(ARROW_STATIC_LIB ${ARROW_LIBDIR}/${ARROW_LIB_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX})
55+
endif()
56+
else()
57+
set(ARROW_HOME "${ARROW_HOME}")
58+
59+
if (MSVC AND NOT ARROW_MSVC_STATIC_LIB_SUFFIX)
60+
set(ARROW_MSVC_STATIC_LIB_SUFFIX _static)
61+
endif()
62+
63+
set(ARROW_SEARCH_HEADER_PATHS
64+
${ARROW_HOME}/include
65+
)
66+
67+
set(ARROW_SEARCH_LIB_PATH
68+
${ARROW_HOME}/lib
69+
)
70+
71+
find_path(ARROW_INCLUDE_DIR arrow/array.h PATHS
72+
${ARROW_SEARCH_HEADER_PATHS}
73+
# make sure we don't accidentally pick up a different version
74+
NO_DEFAULT_PATH
75+
)
76+
77+
find_library(ARROW_LIB_PATH NAMES arrow arrow${ARROW_MSVC_STATIC_LIB_SUFFIX}
78+
PATHS
79+
${ARROW_SEARCH_LIB_PATH}
80+
NO_DEFAULT_PATH)
81+
82+
if (ARROW_INCLUDE_DIR AND (PARQUET_MINIMAL_DEPENDENCY OR ARROW_LIB_PATH))
83+
set(ARROW_FOUND TRUE)
84+
set(ARROW_HEADER_NAME arrow/api.h)
85+
set(ARROW_HEADER ${ARROW_INCLUDE_DIR}/${ARROW_HEADER_NAME})
86+
set(ARROW_LIB_NAME arrow)
87+
88+
get_filename_component(ARROW_LIBS ${ARROW_LIB_PATH} DIRECTORY)
89+
set(ARROW_STATIC_LIB ${ARROW_LIBS}/${CMAKE_STATIC_LIBRARY_PREFIX}${ARROW_LIB_NAME}${ARROW_MSVC_STATIC_LIB_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX})
90+
set(ARROW_SHARED_LIB ${ARROW_LIBS}/${CMAKE_SHARED_LIBRARY_PREFIX}${ARROW_LIB_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX})
91+
set(ARROW_SHARED_IMPLIB ${ARROW_LIBS}/${ARROW_LIB_NAME}.lib)
92+
endif ()
93+
endif()
94+
95+
if (ARROW_FOUND)
96+
if (NOT Arrow_FIND_QUIETLY)
97+
message(STATUS "Arrow include path: ${ARROW_INCLUDE_DIR}")
98+
if (PARQUET_MINIMAL_DEPENDENCY)
99+
message(STATUS "Found the Arrow header: ${ARROW_HEADER}")
100+
else ()
101+
message(STATUS "Found the Arrow library: ${ARROW_LIB_PATH}")
102+
endif ()
103+
endif ()
104+
else()
105+
if (NOT Arrow_FIND_QUIETLY)
106+
set(ARROW_ERR_MSG "Could not find the Arrow library. Looked for headers")
107+
set(ARROW_ERR_MSG "${ARROW_ERR_MSG} in ${ARROW_SEARCH_HEADER_PATHS}, and for libs")
108+
set(ARROW_ERR_MSG "${ARROW_ERR_MSG} in ${ARROW_SEARCH_LIB_PATH}")
109+
if (Arrow_FIND_REQUIRED)
110+
message(FATAL_ERROR "${ARROW_ERR_MSG}")
111+
else (Arrow_FIND_REQUIRED)
112+
message(STATUS "${ARROW_ERR_MSG}")
113+
endif (Arrow_FIND_REQUIRED)
114+
endif ()
115+
endif()
116+
117+
mark_as_advanced(
118+
ARROW_FOUND
119+
ARROW_INCLUDE_DIR
120+
ARROW_STATIC_LIB
121+
ARROW_SHARED_LIB
122+
)

cmake/QualityControlDependencies.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ find_package(CURL REQUIRED)
1212
find_package(ZeroMQ REQUIRED)
1313
find_package(nanomsg REQUIRED)
1414
include_directories(${MS_GSL_INCLUDE_DIR})
15+
find_package(Arrow REQUIRED)
1516

1617
# todo not sure why this is needed
1718
if (BOOST_FOUND AND NOT Boost_FOUND)
@@ -81,6 +82,7 @@ o2_define_bucket(
8182
${ZeroMQ_LIBRARY_SHARED}
8283
${NANOMSG_LIBRARIES}
8384
${AliceO2_LIBRARIES}
85+
${ARROW_SHARED_LIB}
8486

8587
SYSTEMINCLUDE_DIRECTORIES
8688
${Boost_INCLUDE_DIRS}
@@ -95,6 +97,7 @@ o2_define_bucket(
9597
${CURL_INCLUDE_DIRS}
9698
${AliceO2_INCLUDE_DIRS}
9799
${MS_GSL_INCLUDE_DIR}
100+
${ARROW_INCLUDE_DIR}
98101
)
99102

100103
o2_define_bucket(
@@ -120,13 +123,15 @@ o2_define_bucket(
120123
${Monitoring_LIBRARIES}
121124
${InfoLogger_LIBRARIES}
122125
${Common_LIBRARIES}
126+
${ARROW_SHARED_LIB}
123127
QualityControl
124128

125129
SYSTEMINCLUDE_DIRECTORIES
126130
${Boost_INCLUDE_DIRS}
127131
${Monitoring_INCLUDE_DIRS}
128132
${InfoLogger_INCLUDE_DIRS}
129133
${Common_INCLUDE_DIRS}
134+
${ARROW_INCLUDE_DIR}
130135
${CMAKE_SOURCE_DIR}/Framework/include # another module's include dir
131136
)
132137

0 commit comments

Comments
 (0)