arrow icon indicating copy to clipboard operation
arrow copied to clipboard

How can I use arrow in my project as a git submodule

Open g302ge opened this issue 2 years ago • 2 comments

I am currently bootstrap a project using arrow/cpp, I want to use arrow without install it into system lib path. So I use the git command to make the arrow as a submodule, here are two problems

  1. if I can directly using the add_subdirectoy for arrow project
  2. if I use the LZ4 or ZLIB compression lib ,could I mixin them with arrow in one CMakeLists.txt ? If the answer is yes, how to ?

g302ge avatar Aug 12 '22 09:08 g302ge

Here is my solution with cmake

cmake_minimum_required(VERSION 3.11)

# require the submodule 
find_package(Git QUIET)
if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
    option(GIT_SUBMODULE "Check submodules during build" ON)
    if(GIT_SUBMODULE)
        message(STATUS "Submodule update")
        execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
                        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
                        RESULT_VARIABLE GIT_SUBMOD_RESULT)
        if(NOT GIT_SUBMOD_RESULT EQUAL "0")
            message(FATAL_ERROR "git submodule update --init --recursive failed with ${GIT_SUBMOD_RESULT}, please checkout submodules")
        endif()
    endif()
endif()

project(columnar-bench)

# googletest framework
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third_party/googletest)
# benchmark framework
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third_party/benchmark)
# gflags 
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third_party/gflags)
# # snappy 
#add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third_party/snappy)
# # brotil
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third_party/brotli)
# # zlib 
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third_party/zlib)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third_party/zstd/build/cmake)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third_party/lz4/build/cmake)

# arrow 
set(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/arrow_built")
set(CMAKE_INSTALL_LIBDIR "lib")
set(ARROW_CXXFLAGS "-ldl")
set(CMAKE_BUILD_TYPE "Debug")
set(ARROW_PLASMA OFF)
set(ARROW_PYTHON OFF)
set(ARROW_PARQUET ON)
set(ARROW_WITH_ZLIB ON)
set(ARROW_BUILD_BENCHMARKS OFF)
set(ARROW_BUILD_EXAMPLES OFF)
set(ARROW_BUILD_TESTS OFF)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third_party/arrow/cpp)

# binary 
add_executable(reading ${CMAKE_CURRENT_SOURCE_DIR}/src/reading_bench.cc)
add_executable(prepare ${CMAKE_CURRENT_SOURCE_DIR}/src/prepare_data.cc)

but there is still an error

··· CMake Error at third_party/arrow/cpp/src/arrow/CMakeLists.txt:614 (add_dependencies): add_dependencies called with incorrect number of arguments

CMake Error at third_party/arrow/cpp/src/arrow/io/CMakeLists.txt:39 (if): if given arguments:

"NOT" "(" "STREQUAL" "NONE" ")"

Unknown arguments specified ···

g302ge avatar Aug 12 '22 09:08 g302ge

Apache Arrow C++ doesn't support building by add_subdirectory(). Please use ExternalProject_Add() https://cmake.org/cmake/help/latest/module/ExternalProject.html instead.

kou avatar Aug 12 '22 13:08 kou

can someone give an example?

Apache Arrow C++ doesn't support building by add_subdirectory(). Please use ExternalProject_Add() https://cmake.org/cmake/help/latest/module/ExternalProject.html instead.

hqx871 avatar Sep 22 '22 10:09 hqx871

Any solution? @g302ge

ZhangChaoming avatar May 01 '24 16:05 ZhangChaoming