2

Apache Arrow submodule is stored at thirdparty/apache_arrow/cpp, so my main CMakeLists.txt looks like

cmake_minimum_required(VERSION 3.0.0)
project(arrow_parcer VERSION 0.1.0)

add_subdirectory(src)
add_subdirectory(thirdparty/apache_arrow/cpp)

At the thirdparty/apache_arrow stored whole Apache Arrow project.

When I'm trying to build project, last output lines is follow:

[cmake] CMake Error: INSTALL(EXPORT) given unknown export "arrow_targets"
[cmake] Generating done
[cms-driver] Error during CMake configure: [cmake-server] Failed to compute build system.

Apache Arrow can be easily builded by CMakeLists.txt at /cpp folder, but why there is an error if I trying to include it by add_subdirectory?

2 Answers2

3

Apache Arrow C++ is not meant to be built using add_subdirectory, instead you should use CMake's ExternalProject_Add facility to build it:

ExternalProject_Add(arrow_ep 
    URL "https://www.apache.org/dist/arrow/arrow-0.15.1/apache-arrow-0.15.1.tar.gz"
    SOURCE_SUBDIR cpp)

Instead of using URL you can also use different providers like GIT_REPOSITORY, too.

Uwe L. Korn
  • 8,080
  • 1
  • 30
  • 42
  • Is there a way to determine if a given CMake project is intended/able to be consumed by `add_subdirectory()` or if it needs the full `ExternalProject_Add()` treatment? – genpfault Jan 27 '20 at 21:20
  • I'm trying to use Apache Arrow Data Types in my C++ project and as I've seen in your C++ implementation documentation on your official website, I need to include the header . Although I added Apache Arrow to my project the same way you mentioned in your answer, I'm still receiving the error arrow/api.h not found. Am I missing something here? – eyadMhanna Jan 30 '20 at 14:03
  • You will need to also need to add an `include_directories` directive that points to the directory where the built artifacts are. See how we do this for snappy in Arrow: https://github.com/apache/arrow/blob/master/cpp/cmake_modules/ThirdpartyToolchain.cmake#L701-L717 Similar lines are needed in addition to `ExternalProject_Add`. – Uwe L. Korn Feb 04 '20 at 08:13
  • @genpfault I think the "way" to determine is: 1. if this project is really important to your main project; 2. if you have enough time and patience to read the external project's CMake and whole build system. You can use `add_subdirectory` to consume any project if you allow there are some hacks and workarounds. – Jackal Cooper Dec 15 '21 at 13:14
1

If you don't really need to setup the installation, here is a hack-y way to do this. In the CMakeLists.txt adding arrow's source dir, you define your own install.

function(install)
endfunction()
add_subdirectory(${arrow_SOURCE_DIR}/cpp ${arrow_BINARY_DIR})