This is an automated email from the ASF dual-hosted git repository.
weibin pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-graphar.git
The following commit(s) were added to refs/heads/main by this push:
new d00c3649 feat(c++): support static graphar (#541)
d00c3649 is described below
commit d00c3649d2fdee6ba0fbf612b473707688d60e3f
Author: Liu Jiajun <[email protected]>
AuthorDate: Thu Jul 18 14:39:01 2024 +0800
feat(c++): support static graphar (#541)
* use static arrow
* fix ci
* update arrow in ci
---
.github/workflows/ci.yml | 30 ++++++++++++++---
cpp/CMakeLists.txt | 84 ++++++++++++++++++++++++++++++++++++++----------
cpp/README.md | 5 +++
3 files changed, 98 insertions(+), 21 deletions(-)
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 88119cbf..394c839d 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -56,10 +56,10 @@ jobs:
-P /tmp/
sudo apt-get install -y
/tmp/apache-arrow-apt-source-latest-"$(lsb_release --codename --short)".deb
sudo apt-get update -y
- sudo apt install -y libarrow-dev=14.0.1-1 \
- libarrow-dataset-dev=14.0.1-1 \
- libarrow-acero-dev=14.0.1-1 \
- libparquet-dev=14.0.1-1
+ sudo apt install -y libarrow-dev \
+ libarrow-dataset-dev \
+ libarrow-acero-dev \
+ libparquet-dev
sudo apt-get install -y libboost-graph-dev ccache libcurl4-openssl-dev
doxygen
# install benchmark
@@ -153,6 +153,17 @@ jobs:
./graph_info_benchmark
./arrow_chunk_reader_benchmark
+ - name: Use Static Arrow
+ working-directory: "cpp"
+ run: |
+ mkdir build-static
+ pushd build-static
+ cmake .. -DUSE_STATIC_ARROW=ON -DCMAKE_BUILD_TYPE=Debug
-DBUILD_TESTS=ON -DBUILD_EXAMPLES=ON -DBUILD_BENCHMARKS=ON
+ make -j$(nproc)
+ export ASAN_OPTIONS=detect_leaks=0
+ ctest --output-on-failure
+ popd
+
macos:
name: ${{ matrix.architecture }} macOS ${{ matrix.macos-version }} C++
runs-on: macos-${{ matrix.macos-version }}
@@ -193,3 +204,14 @@ jobs:
run: |
export ASAN_OPTIONS=detect_leaks=0
ctest --output-on-failure
+
+ - name: Use Static Arrow
+ working-directory: "cpp"
+ run: |
+ mkdir build-static
+ pushd build-static
+ cmake .. -DUSE_STATIC_ARROW=ON -DCMAKE_BUILD_TYPE=Debug
-DBUILD_TESTS=ON -DBUILD_EXAMPLES=ON -DBUILD_BENCHMARKS=ON
+ make -j$(nproc)
+ export ASAN_OPTIONS=detect_leaks=0
+ ctest --output-on-failure
+ popd
\ No newline at end of file
diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt
index c0d39d3a..d5737bdc 100644
--- a/cpp/CMakeLists.txt
+++ b/cpp/CMakeLists.txt
@@ -46,6 +46,12 @@ option(BUILD_EXAMPLES "Build examples" OFF)
option(BUILD_BENCHMARKS "Build benchmarks" OFF)
option(ENABLE_DOCS "Enable documentation" OFF)
option(BUILD_DOCS_ONLY "Build docs only" OFF)
+option(USE_STATIC_ARROW "Link arrow static library" OFF)
+option(GRAPHAR_BUILD_STATIC "Build GraphAr as static libraries" OFF)
+
+if (USE_STATIC_ARROW)
+ set(GRAPHAR_BUILD_STATIC ON)
+endif()
if (ENABLE_DOCS OR BUILD_DOCS_ONLY)
set(PROJECT_DOCUMENT_SOURCE ${PROJECT_SOURCE_DIR}/include
${PROJECT_SOURCE_DIR}/README.md)
@@ -214,7 +220,11 @@ include_directories(src)
macro(build_graphar)
file(GLOB_RECURSE CORE_SRC_FILES "src/graphar/*.cc"
${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/mini-yaml/yaml/*.cpp)
- add_library(graphar SHARED ${CORE_SRC_FILES})
+ if(GRAPHAR_BUILD_STATIC)
+ add_library(graphar STATIC ${CORE_SRC_FILES})
+ else()
+ add_library(graphar SHARED ${CORE_SRC_FILES})
+ endif()
install_graphar_target(graphar)
target_compile_features(graphar PRIVATE cxx_std_17)
target_include_directories(graphar PUBLIC
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
@@ -224,15 +234,31 @@ macro(build_graphar)
target_link_libraries(graphar PRIVATE ${CMAKE_DL_LIBS})
if(APPLE)
- target_link_libraries(graphar PRIVATE -Wl,-force_load
Arrow::arrow_shared
- Parquet::parquet_shared
- ArrowDataset::arrow_dataset_shared
- ArrowAcero::arrow_acero_shared)
+ if(USE_STATIC_ARROW)
+ target_link_libraries(graphar PRIVATE -Wl,-force_load
+ Arrow::arrow_static
+ Parquet::parquet_static
+ ArrowDataset::arrow_dataset_static
+ ArrowAcero::arrow_acero_static)
+ else()
+ target_link_libraries(graphar PRIVATE -Wl,-force_load
Arrow::arrow_shared
+ Parquet::parquet_shared
+ ArrowDataset::arrow_dataset_shared
+ ArrowAcero::arrow_acero_shared)
+ endif()
else()
- target_link_libraries(graphar PRIVATE -Wl,--exclude-libs,ALL
-Wl,--whole-archive Arrow::arrow_shared
- Parquet::parquet_shared
- ArrowDataset::arrow_dataset_shared
- ArrowAcero::arrow_acero_shared -Wl,--no-whole-archive)
+ if(USE_STATIC_ARROW)
+ target_link_libraries(graphar PRIVATE -Wl,--exclude-libs,ALL
-Wl,--whole-archive
+ Arrow::arrow_static
+ Parquet::parquet_static
+ ArrowDataset::arrow_dataset_static
+ ArrowAcero::arrow_acero_static -Wl,--no-whole-archive)
+ else()
+ target_link_libraries(graphar PRIVATE -Wl,--exclude-libs,ALL
-Wl,--whole-archive Arrow::arrow_shared
+ Parquet::parquet_shared
+ ArrowDataset::arrow_dataset_shared
+ ArrowAcero::arrow_acero_shared -Wl,--no-whole-archive)
+ endif()
endif()
endmacro()
@@ -258,11 +284,23 @@ if (BUILD_EXAMPLES)
target_include_directories(${E_NAME} SYSTEM PRIVATE
${Boost_INCLUDE_DIRS})
target_link_libraries(${E_NAME} PRIVATE graphar ${Boost_LIBRARIES}
${CMAKE_DL_LIBS})
if(APPLE)
- target_link_libraries(${E_NAME} PRIVATE Arrow::arrow_shared
- Parquet::parquet_shared)
+ if(USE_STATIC_ARROW)
+ target_link_libraries(${E_NAME} PRIVATE -Wl,-force_load
+ Arrow::arrow_static
+ Parquet::parquet_static)
+ else()
+ target_link_libraries(${E_NAME} PRIVATE Arrow::arrow_shared
+ Parquet::parquet_shared)
+ endif()
else()
- target_link_libraries(${E_NAME} PRIVATE Arrow::arrow_shared
- Parquet::parquet_shared)
+ if(USE_STATIC_ARROW)
+ target_link_libraries(${E_NAME} PRIVATE -Wl,--exclude-libs,ALL
-Wl,--whole-archive
+ Arrow::arrow_static
+ Parquet::parquet_static -Wl,--no-whole-archive)
+ else()
+ target_link_libraries(${E_NAME} PRIVATE Arrow::arrow_shared
+ Parquet::parquet_shared)
+ endif()
endif()
endforeach()
endif()
@@ -316,11 +354,23 @@ if (BUILD_TESTS)
target_include_directories(${target} PRIVATE
${PROJECT_SOURCE_DIR}/thirdparty)
target_link_libraries(${target} PRIVATE Catch2::Catch2WithMain graphar
${CMAKE_DL_LIBS})
if(APPLE)
- target_link_libraries(${target} PRIVATE Arrow::arrow_shared
- Parquet::parquet_shared)
+ if(USE_STATIC_ARROW)
+ target_link_libraries(${target} PRIVATE -Wl,-force_load
+ Arrow::arrow_static
+ Parquet::parquet_static)
+ else()
+ target_link_libraries(${target} PRIVATE Arrow::arrow_shared
+ Parquet::parquet_shared)
+ endif()
else()
- target_link_libraries(${target} PRIVATE Arrow::arrow_shared
- Parquet::parquet_shared)
+ if(USE_STATIC_ARROW)
+ target_link_libraries(${target} PRIVATE -Wl,--exclude-libs,ALL
-Wl,--whole-archive
+ Arrow::arrow_static
+ Parquet::parquet_static -Wl,--no-whole-archive)
+ else()
+ target_link_libraries(${target} PRIVATE Arrow::arrow_shared
+ Parquet::parquet_shared)
+ endif()
endif()
target_include_directories(${target} PRIVATE
${PROJECT_SOURCE_DIR}/include
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/Catch2/single_include>)
include(CTest)
diff --git a/cpp/README.md b/cpp/README.md
index a1c59831..d5241431 100644
--- a/cpp/README.md
+++ b/cpp/README.md
@@ -111,6 +111,11 @@ Build with benchmarks, you should build the project with
`BUILD_BENCHMARKS` opti
$ GAR_TEST_DATA=${PWD}/testing ./graph_info_benchmark # run the graph
info benchmark
```
+Extra Build Options:
+
+1. `-DGRAPHAR_BUILD_STATIC=ON`: Build GraphAr as static libraries.
+2. `-DUSE_STATIC_ARROW=ON`: Link arrow static library to build GraphAr. If set
this option, the option `GRAPHAR_BUILD_STATIC=ON` will be set.
+
### Install
After the building, you can install the GraphAr C++ library with:
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]