What is the best way of using arrow parquet in more modern cmake?

Viewed 595

Below is the solution that worked for me, but not sure if it is the best way to do this. I used brew to install it. vcpkg does not work at the moment, unfortunately. What I don't like about this solution is that I need to set Parquet_DIR and find_package(Parquet) separately.

set(Parquet_DIR /usr/local/lib/cmake/arrow)

find_package(Arrow CONFIG REQUIRED)
find_package(Parquet CONFIG REQUIRED)
target_link_libraries(database PRIVATE arrow_shared parquet_shared)
3 Answers

You can pass PATHS to search to find_package.

You may also want to prevent searching in other places by passing NO_DEFAULT_PATH.

See find_package documentation

find_package(Arrow CONFIG REQUIRED)
find_package(Parquet CONFIG REQUIRED
    PATHS /usr/local/lib/cmake/arrow
    NO_DEFAULT_PATH
)
target_link_libraries(database PRIVATE arrow_shared parquet_shared)

(The above snippet assumes that Arrow does not depend on the Parquet package.)

As fabian's workaround, you'd use find_package(Parquet CONFIG REQUIRED PATHS ${Arrow_DIR} NO_DEFAULT_PATH) to avoid absolute path, which is more flexiable.

I manage to build parquet only without using find_package or ExternalProject_Add. Here is my CMakeLists.txt:

# FetchContent and populate...
# Setting your CMake flags...
set(ARROW_SIMD_LEVEL "NONE" CACHE STRING "" FORCE)
set(ARROW_OPTIONAL_INSTALL OFF)
set(Thrift_SOURCE "BUNDLED")
set(BOOST_SOURCE "BUNDLED")
set(ARROW_BUILD_TESTS OFF)
set(ARROW_PARQUET ON)
set(PARQUET_MINIMAL_DEPENDENCY OFF)
include(CMakePackageConfigHelpers)
function(install)
endfunction()
add_subdirectory(${arrow_SOURCE_DIR}/cpp ${arrow_BINARY_DIR})
add_dependencies(parquet_objlib thrift_ep boost_ep) # Had to add this line. Not sure why the proper dependencies are not there.
Related