Skip to content

Commit a17b42d

Browse files
authored
[C++][BugFix] Fix the arrow acero not found error when building with arrow 12.0.0 or greater (#164)
* Fix the arrow acero not found error when building with arrow 12.0.0 or later Signed-off-by: acezen <qiaozi.zwb@alibaba-inc.com> Committed-by: acezen from Dev container
1 parent 1bc4656 commit a17b42d

File tree

3 files changed

+27
-8
lines changed

3 files changed

+27
-8
lines changed

.github/workflows/ci.yml

+6
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,13 @@ jobs:
4646
4747
- name: Install dependencies
4848
run: |
49+
50+
# install the latest arrow deb to test arrow
51+
wget -c https://apache.jfrog.io/artifactory/arrow/"$(lsb_release --id --short | tr 'A-Z' 'a-z')"/apache-arrow-apt-source-latest-$(lsb_release --codename --short).deb \
52+
-P /tmp/
53+
sudo apt-get install -y -V /tmp/apache-arrow-apt-source-latest-"$(lsb_release --codename --short)".deb
4954
sudo apt-get update -y
55+
sudo apt-get install -y libarrow-dev
5056
sudo apt-get install -y libboost-graph-dev ccache libcurl4-openssl-dev
5157
5258
- name: CMake

cpp/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,12 @@ macro(build_gar)
191191
if(APPLE)
192192
target_link_libraries(gar PRIVATE -Wl,-force_load gar_arrow_static
193193
"${GAR_PARQUET_STATIC_LIB}"
194+
"${GAR_ACERO_STATIC_LIB}"
194195
"${GAR_ARROW_BUNDLED_DEPS_STATIC_LIB}")
195196
else()
196197
target_link_libraries(gar PRIVATE -Wl,--exclude-libs,ALL -Wl,--whole-archive gar_arrow_static
197198
"${GAR_PARQUET_STATIC_LIB}"
199+
"${GAR_ARROW_ACERO_STATIC_LIB}"
198200
"${GAR_ARROW_BUNDLED_DEPS_STATIC_LIB}" -Wl,--no-whole-archive)
199201
endif()
200202

cpp/cmake/apache-arrow.cmake

+19-8
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,6 @@ function(build_arrow)
3333
message(SEND_ERROR "Error: unrecognized arguments: ${ARG_UNPARSED_ARGUMENTS}")
3434
endif ()
3535

36-
find_package(Threads)
37-
find_package(Arrow QUIET)
38-
set(ARROW_VERSION_TO_BUILD "10.0.1" CACHE INTERNAL "arrow version")
39-
if (Arrow_FOUND) # arrow is installed, build the same version as the installed one
40-
message(STATUS "Found Arrow installed, align to version: ${Arrow_VERSION}")
41-
set(ARROW_VERSION_TO_BUILD "${Arrow_VERSION}" CACHE INTERNAL "arrow version")
42-
endif ()
43-
4436
# If Arrow needs to be built, the default location will be within the build tree.
4537
set(GAR_ARROW_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/arrow_ep-prefix")
4638

@@ -78,6 +70,7 @@ function(build_arrow)
7870
"-DBoost_SOURCE=BUNDLED"
7971
"-DARROW_ORC=ON"
8072
"-DARROW_COMPUTE=ON"
73+
"-DARROW_ACERO=ON"
8174
"-DARROW_DATASET=ON"
8275
"-DARROW_JEMALLOC=OFF"
8376
"-DARROW_WITH_SNAPPY=OFF"
@@ -91,6 +84,14 @@ function(build_arrow)
9184

9285
set(GAR_ARROW_INCLUDE_DIR "${GAR_ARROW_PREFIX}/include" CACHE INTERNAL "arrow include directory")
9386
set(GAR_ARROW_BUILD_BYPRODUCTS "${GAR_ARROW_STATIC_LIB}" "${GAR_PARQUET_STATIC_LIB}")
87+
88+
find_package(Threads)
89+
find_package(Arrow QUIET)
90+
set(ARROW_VERSION_TO_BUILD "10.0.1" CACHE INTERNAL "arrow version")
91+
if (Arrow_FOUND) # arrow is installed, build the same version as the installed one
92+
message(STATUS "Found Arrow installed, align to version: ${Arrow_VERSION}")
93+
set(ARROW_VERSION_TO_BUILD "${Arrow_VERSION}" CACHE INTERNAL "arrow version")
94+
endif ()
9495
set(GAR_ARROW_SOURCE_FILE "https://www.apache.org/dyn/closer.lua?action=download&filename=arrow/arrow-${ARROW_VERSION_TO_BUILD}/apache-arrow-${ARROW_VERSION_TO_BUILD}.tar.gz")
9596

9697
include(ExternalProject)
@@ -113,6 +114,16 @@ function(build_arrow)
113114
set_target_properties(${GAR_PARQUET_LIBRARY_TARGET}
114115
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${GAR_ARROW_INCLUDE_DIR}
115116
IMPORTED_LOCATION ${GAR_PARQUET_STATIC_LIB})
117+
if (ARROW_VERSION_TO_BUILD GREATER_EQUAL "12.0.0")
118+
set(GAR_ARROW_ACERO_STATIC_LIB_FILENAME
119+
"${CMAKE_STATIC_LIBRARY_PREFIX}arrow_acero${CMAKE_STATIC_LIBRARY_SUFFIX}")
120+
set(GAR_ARROW_ACERO_STATIC_LIB "${GAR_ARROW_STATIC_LIBRARY_DIR}/${GAR_ARROW_ACERO_STATIC_LIB_FILENAME}" CACHE INTERNAL "acero lib")
121+
set(GAR_ARROW_ACERO_LIBRARY_TARGET gar_acero_static)
122+
add_library(${GAR_ARROW_ACERO_LIBRARY_TARGET} STATIC IMPORTED)
123+
set_target_properties(${GAR_ARROW_ACERO_LIBRARY_TARGET}
124+
PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${GAR_ARROW_INCLUDE_DIR}
125+
IMPORTED_LOCATION ${GAR_ARROW_ACERO_STATIC_LIB})
126+
endif()
116127

117128
add_dependencies(${GAR_ARROW_LIBRARY_TARGET} arrow_ep)
118129
endfunction()

0 commit comments

Comments
 (0)