diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 27d7097a2901f..2aeb0b1dd070a 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -499,12 +499,18 @@ set(ARROW_PC_CFLAGS_PRIVATE " -DARROW_STATIC") set(ARROW_PC_LIBS_PRIVATE "") set(ARROW_PC_REQUIRES_PRIVATE "") +# For arrow-flight.pc. +set(ARROW_FLIGHT_PC_REQUIRES_PRIVATE "") + # For arrow-testing.pc. set(ARROW_TESTING_PC_CFLAGS "") set(ARROW_TESTING_PC_CFLAGS_PRIVATE " -DARROW_TESTING_STATIC") set(ARROW_TESTING_PC_LIBS "") set(ARROW_TESTING_PC_REQUIRES "") +# For parquet.pc. +set(PARQUET_PC_REQUIRES_PRIVATE "") + include(ThirdpartyToolchain) # Add common flags diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index 1767c05b5ee3a..3101c1dc73aa6 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -32,6 +32,9 @@ set(ARROW_BUNDLED_STATIC_LIBS) # Accumulate all system dependencies to provide suitable static link # parameters to the third party libraries. set(ARROW_SYSTEM_DEPENDENCIES) +set(ARROW_FLIGHT_SYSTEM_DEPENDENCIES) +set(ARROW_TESTING_SYSTEM_DEPENDENCIES) +set(PARQUET_SYSTEM_DEPENDENCIES) # ---------------------------------------------------------------------- # Toolchain linkage options @@ -233,6 +236,7 @@ macro(resolve_dependency DEPENDENCY_NAME) set(options) set(one_value_args ARROW_CMAKE_PACKAGE_NAME + ARROW_PC_PACKAGE_NAME FORCE_ANY_NEWER_VERSION HAVE_ALT IS_RUNTIME_DEPENDENCY @@ -297,12 +301,26 @@ macro(resolve_dependency DEPENDENCY_NAME) if(NOT ARG_ARROW_CMAKE_PACKAGE_NAME) set(ARG_ARROW_CMAKE_PACKAGE_NAME "Arrow") endif() - if(ARG_ARROW_CMAKE_PACKAGE_NAME STREQUAL "Arrow") - provide_find_module(${PACKAGE_NAME} "Arrow") - list(APPEND ARROW_SYSTEM_DEPENDENCIES ${PACKAGE_NAME}) - else() - provide_find_module(${PACKAGE_NAME} ${ARG_ARROW_CMAKE_PACKAGE_NAME}) + # ArrowFlight -> _Arrow_Flight + string(REGEX REPLACE "([A-Z])" "_\\1" ARG_ARROW_CMAKE_PACKAGE_NAME_SNAKE + ${ARG_ARROW_CMAKE_PACKAGE_NAME}) + # _Arrow_Flight -> Arrow_Flight + string(SUBSTRING ${ARG_ARROW_CMAKE_PACKAGE_NAME_SNAKE} 1 -1 + ARG_ARROW_CMAKE_PACKAGE_NAME_SNAKE) + # Arrow_Flight -> ARROW_FLIGHT + string(TOUPPER ${ARG_ARROW_CMAKE_PACKAGE_NAME_SNAKE} + ARG_ARROW_CMAKE_PACKAGE_NAME_UPPER_SNAKE) + provide_find_module(${PACKAGE_NAME} ${ARG_ARROW_CMAKE_PACKAGE_NAME}) + list(APPEND ${ARG_ARROW_CMAKE_PACKAGE_NAME_UPPER_SNAKE}_SYSTEM_DEPENDENCIES + ${PACKAGE_NAME}) + if(NOT ARG_ARROW_PC_PACKAGE_NAME) + set(ARG_ARROW_PC_PACKAGE_NAME "arrow") endif() + # arrow-flight -> arrow_flight + string(REPLACE "-" "_" ARG_ARROW_PC_PACKAGE_NAME_SNAKE ${ARG_ARROW_PC_PACKAGE_NAME}) + # arrow_flight -> ARROW_FLIGHT + string(TOUPPER ${ARG_ARROW_PC_PACKAGE_NAME_SNAKE} + ARG_ARROW_PC_PACKAGE_NAME_UPPER_SNAKE) if(ARROW_BUILD_STATIC) find_package(PkgConfig QUIET) foreach(ARG_PC_PACKAGE_NAME ${ARG_PC_PACKAGE_NAMES}) @@ -311,13 +329,16 @@ macro(resolve_dependency DEPENDENCY_NAME) NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH QUIET) + set(RESOLVE_DEPENDENCY_PC_PACKAGE + "pkg-config package for ${ARG_PC_PACKAGE_NAME} ") + string(APPEND RESOLVE_DEPENDENCY_PC_PACKAGE + "that is used by ${ARG_ARROW_PC_PACKAGE_NAME} for static link") if(${${ARG_PC_PACKAGE_NAME}_PC_FOUND}) - message(STATUS "Using pkg-config package for ${ARG_PC_PACKAGE_NAME} for static link" - ) - string(APPEND ARROW_PC_REQUIRES_PRIVATE " ${ARG_PC_PACKAGE_NAME}") + message(STATUS "Using ${RESOLVE_DEPENDENCY_PC_PACKAGE}") + string(APPEND ${ARG_ARROW_PC_PACKAGE_NAME_UPPER_SNAKE}_PC_REQUIRES_PRIVATE + " ${ARG_PC_PACKAGE_NAME}") else() - message(STATUS "pkg-config package for ${ARG_PC_PACKAGE_NAME} for static link isn't found" - ) + message(STATUS "${RESOLVE_DEPENDENCY_PC_PACKAGE} isn't found") endif() endforeach() endif() @@ -1614,12 +1635,16 @@ endmacro() if(ARROW_WITH_THRIFT) # Thrift C++ code generated by 0.13 requires 0.11 or greater resolve_dependency(Thrift + ARROW_CMAKE_PACKAGE_NAME + Parquet + ARROW_PC_PACKAGE_NAME + parquet HAVE_ALT TRUE - REQUIRED_VERSION - 0.11.0 PC_PACKAGE_NAMES - thrift) + thrift + REQUIRED_VERSION + 0.11.0) string(REPLACE "." ";" Thrift_VERSION_LIST ${Thrift_VERSION}) list(GET Thrift_VERSION_LIST 0 Thrift_VERSION_MAJOR) @@ -1715,6 +1740,13 @@ if(ARROW_WITH_PROTOBUF) else() set(ARROW_PROTOBUF_REQUIRED_VERSION "2.6.1") endif() + if(ARROW_FLIGHT) + set(ARROW_PROTOBUF_ARROW_CMAKE_PACKAGE_NAME "ArrowFlight") + set(ARROW_PROTOBUF_ARROW_PC_PACKAGE_NAME "arrow-flight") + else() + set(ARROW_PROTOBUF_ARROW_CMAKE_PACKAGE_NAME "Arrow") + set(ARROW_PROTOBUF_ARROW_PC_PACKAGE_NAME "arrow") + endif() # We need to use FORCE_ANY_NEWER_VERSION here to accept Protobuf # newer version such as 23.4. If we don't use it, 23.4 is processed # as an incompatible version with 3.12.0 with protobuf-config.cmake @@ -1724,14 +1756,18 @@ if(ARROW_WITH_PROTOBUF) # we use FORCE_ANY_NEWER_VERSION here, we can bypass the check and # use 23.4. resolve_dependency(Protobuf + ARROW_CMAKE_PACKAGE_NAME + ${ARROW_PROTOBUF_ARROW_CMAKE_PACKAGE_NAME} + ARROW_PC_PACKAGE_NAME + ${ARROW_PROTOBUF_ARROW_PC_PACKAGE_NAME} FORCE_ANY_NEWER_VERSION TRUE HAVE_ALT TRUE - REQUIRED_VERSION - ${ARROW_PROTOBUF_REQUIRED_VERSION} PC_PACKAGE_NAMES - protobuf) + protobuf + REQUIRED_VERSION + ${ARROW_PROTOBUF_REQUIRED_VERSION}) if(NOT Protobuf_USE_STATIC_LIBS AND MSVC_TOOLCHAIN) add_definitions(-DPROTOBUF_USE_DLLS) @@ -2167,12 +2203,12 @@ endmacro() if(ARROW_TESTING) set(GTestAlt_NEED_CXX_STANDARD_CHECK TRUE) resolve_dependency(GTest + ARROW_CMAKE_PACKAGE_NAME + ArrowTesting HAVE_ALT TRUE REQUIRED_VERSION - 1.10.0 - ARROW_CMAKE_PACKAGE_NAME - "ArrowTesting") + 1.10.0) if(GTest_SOURCE STREQUAL "SYSTEM") find_package(PkgConfig QUIET) @@ -2351,10 +2387,12 @@ endif() if(ARROW_USE_XSIMD) resolve_dependency(xsimd + FORCE_ANY_NEWER_VERSION + TRUE REQUIRED_VERSION "8.1.0" - FORCE_ANY_NEWER_VERSION - TRUE) + PC_PACKAGE_NAMES + xsimd) if(xsimd_SOURCE STREQUAL "BUNDLED") add_library(arrow::xsimd INTERFACE IMPORTED) @@ -2678,10 +2716,10 @@ endmacro() if(ARROW_WITH_UTF8PROC) resolve_dependency(utf8proc - REQUIRED_VERSION - "2.2.0" PC_PACKAGE_NAMES - libutf8proc) + libutf8proc + REQUIRED_VERSION + "2.2.0") add_definitions(-DARROW_WITH_UTF8PROC) endif() @@ -3694,6 +3732,10 @@ endmacro() macro(build_grpc) resolve_dependency(c-ares + ARROW_CMAKE_PACKAGE_NAME + ArrowFlight + ARROW_PC_PACKAGE_NAME + arrow-flight HAVE_ALT TRUE PC_PACKAGE_NAMES @@ -3998,12 +4040,16 @@ if(ARROW_WITH_GRPC) set(gRPC_SOURCE "${Protobuf_SOURCE}") endif() resolve_dependency(gRPC + ARROW_CMAKE_PACKAGE_NAME + ArrowFlight + ARROW_PC_PACKAGE_NAME + arrow-flight HAVE_ALT TRUE - REQUIRED_VERSION - ${ARROW_GRPC_REQUIRED_VERSION} PC_PACKAGE_NAMES - grpc++) + grpc++ + REQUIRED_VERSION + ${ARROW_GRPC_REQUIRED_VERSION}) if(GRPC_VENDORED) # Remove "v" from "vX.Y.Z" @@ -5119,7 +5165,13 @@ macro(build_ucx) endmacro() if(ARROW_WITH_UCX) - resolve_dependency(ucx PC_PACKAGE_NAMES ucx) + resolve_dependency(ucx + ARROW_CMAKE_PACKAGE_NAME + ArrowFlight + ARROW_PC_PACKAGE_NAME + arrow-flight + PC_PACKAGE_NAMES + ucx) add_library(ucx::ucx INTERFACE IMPORTED) target_include_directories(ucx::ucx INTERFACE "${UCX_INCLUDE_DIRS}") target_link_libraries(ucx::ucx INTERFACE ucx::ucp ucx::uct ucx::ucs) diff --git a/cpp/src/arrow/ArrowConfig.cmake.in b/cpp/src/arrow/ArrowConfig.cmake.in index deb7bf94a80a2..7bd19fb41a31f 100644 --- a/cpp/src/arrow/ArrowConfig.cmake.in +++ b/cpp/src/arrow/ArrowConfig.cmake.in @@ -41,13 +41,7 @@ set(ARROW_SYSTEM_DEPENDENCIES "@ARROW_SYSTEM_DEPENDENCIES@") include("${CMAKE_CURRENT_LIST_DIR}/ArrowOptions.cmake") -if(ARROW_BUILD_STATIC) - include(CMakeFindDependencyMacro) - - set(CMAKE_THREAD_PREFER_PTHREAD TRUE) - set(THREADS_PREFER_PTHREAD_FLAG TRUE) - find_dependency(Threads) - +macro(arrow_find_dependencies dependencies) if(DEFINED CMAKE_MODULE_PATH) set(ARROW_CMAKE_MODULE_PATH_OLD ${CMAKE_MODULE_PATH}) else() @@ -55,9 +49,9 @@ if(ARROW_BUILD_STATIC) endif() set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}") - foreach(_DEPENDENCY ${ARROW_SYSTEM_DEPENDENCIES}) + foreach(dependency ${dependencies}) set(ARROW_OPENSSL_HOMEBREW_MAKE_DETECTABLE FALSE) - if(${_DEPENDENCY} STREQUAL "OpenSSL" AND NOT OPENSSL_ROOT_DIR) + if(${dependency} STREQUAL "OpenSSL" AND NOT OPENSSL_ROOT_DIR) find_program(ARROW_BREW brew) if(ARROW_BREW) set(ARROW_OPENSSL_ROOT_DIR_ORIGINAL ${OPENSSL_ROOT_DIR}) @@ -78,7 +72,7 @@ if(ARROW_BUILD_STATIC) endif() endif() endif() - find_dependency(${_DEPENDENCY}) + find_dependency(${dependency}) if(ARROW_OPENSSL_HOMEBREW_MAKE_DETECTABLE) set(OPENSSL_ROOT_DIR ${ARROW_OPENSSL_ROOT_DIR_ORIGINAL}) endif() @@ -90,6 +84,16 @@ if(ARROW_BUILD_STATIC) else() unset(CMAKE_MODULE_PATH) endif() +endmacro() + +if(ARROW_BUILD_STATIC) + include(CMakeFindDependencyMacro) + + set(CMAKE_THREAD_PREFER_PTHREAD TRUE) + set(THREADS_PREFER_PTHREAD_FLAG TRUE) + find_dependency(Threads) + + arrow_find_dependencies("${ARROW_SYSTEM_DEPENDENCIES}") endif() include("${CMAKE_CURRENT_LIST_DIR}/ArrowTargets.cmake") diff --git a/cpp/src/arrow/ArrowTestingConfig.cmake.in b/cpp/src/arrow/ArrowTestingConfig.cmake.in index b65f6ef0d58b0..148d6516a093f 100644 --- a/cpp/src/arrow/ArrowTestingConfig.cmake.in +++ b/cpp/src/arrow/ArrowTestingConfig.cmake.in @@ -26,26 +26,12 @@ @PACKAGE_INIT@ -set(ARROW_GTEST_SOURCE "@GTest_SOURCE@") +set(ARROW_TESTING_SYSTEM_DEPENDENCIES "@ARROW_TESTING_SYSTEM_DEPENDENCIES@") include(CMakeFindDependencyMacro) find_dependency(Arrow) -if(DEFINED CMAKE_MODULE_PATH) - set(ARROW_TESTING_CMAKE_MODULE_PATH_OLD ${CMAKE_MODULE_PATH}) -else() - unset(ARROW_TESTING_CMAKE_MODULE_PATH_OLD) -endif() -set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}") -if("${ARROW_GTEST_SOURCE}" STREQUAL "SYSTEM") - find_dependency(GTestAlt) -endif() -if(DEFINED ARROW_TESTING_CMAKE_MODULE_PATH_OLD) - set(CMAKE_MODULE_PATH ${ARROW_TESTING_CMAKE_MODULE_PATH_OLD}) - unset(ARROW_TESTING_CMAKE_MODULE_PATH_OLD) -else() - unset(CMAKE_MODULE_PATH) -endif() +arrow_find_dependencies("${ARROW_TESTING_SYSTEM_DEPENDENCIES}") include("${CMAKE_CURRENT_LIST_DIR}/ArrowTestingTargets.cmake") diff --git a/cpp/src/arrow/flight/ArrowFlightConfig.cmake.in b/cpp/src/arrow/flight/ArrowFlightConfig.cmake.in index 70beb901c857f..92803289f1ea8 100644 --- a/cpp/src/arrow/flight/ArrowFlightConfig.cmake.in +++ b/cpp/src/arrow/flight/ArrowFlightConfig.cmake.in @@ -26,9 +26,15 @@ @PACKAGE_INIT@ +set(ARROW_FLIGHT_SYSTEM_DEPENDENCIES "@ARROW_FLIGHT_SYSTEM_DEPENDENCIES@") + include(CMakeFindDependencyMacro) find_dependency(Arrow) +if(ARROW_BUILD_STATIC) + arrow_find_dependencies("${ARROW_FLIGHT_SYSTEM_DEPENDENCIES}") +endif() + include("${CMAKE_CURRENT_LIST_DIR}/ArrowFlightTargets.cmake") arrow_keep_backward_compatibility(ArrowFlight arrow_flight) diff --git a/cpp/src/arrow/flight/arrow-flight.pc.in b/cpp/src/arrow/flight/arrow-flight.pc.in index 5a57a8922377e..a63d6cadaa80e 100644 --- a/cpp/src/arrow/flight/arrow-flight.pc.in +++ b/cpp/src/arrow/flight/arrow-flight.pc.in @@ -23,5 +23,6 @@ Name: Apache Arrow Flight Description: Apache Arrow's RPC system built on gRPC Version: @ARROW_VERSION@ Requires: arrow +Requires.private:@ARROW_FLIGHT_PC_REQUIRES_PRIVATE@ Libs: -L${libdir} -larrow_flight Cflags.private: -DARROW_FLIGHT_STATIC diff --git a/cpp/src/parquet/ParquetConfig.cmake.in b/cpp/src/parquet/ParquetConfig.cmake.in index 1030530138865..6e212690a7c92 100644 --- a/cpp/src/parquet/ParquetConfig.cmake.in +++ b/cpp/src/parquet/ParquetConfig.cmake.in @@ -29,9 +29,15 @@ @PACKAGE_INIT@ +set(PARQUET_SYSTEM_DEPENDENCIES "@PARQUET_FLIGHT_SYSTEM_DEPENDENCIES@") + include(CMakeFindDependencyMacro) find_dependency(Arrow) +if(ARROW_BUILD_STATIC) + arrow_find_dependencies("${PARQUET_SYSTEM_DEPENDENCIES}") +endif() + set(PARQUET_VERSION "@ARROW_VERSION@") set(PARQUET_SO_VERSION "@ARROW_SO_VERSION@") set(PARQUET_FULL_SO_VERSION "@ARROW_FULL_SO_VERSION@") diff --git a/cpp/src/parquet/parquet.pc.in b/cpp/src/parquet/parquet.pc.in index b992eba81998a..6def1c5d8b399 100644 --- a/cpp/src/parquet/parquet.pc.in +++ b/cpp/src/parquet/parquet.pc.in @@ -27,6 +27,7 @@ Name: Apache Parquet Description: Apache Parquet is a columnar storage format. Version: @ARROW_VERSION@ Requires: arrow +Requires.private:@PARQUET_PC_REQUIRES_PRIVATE@ Libs: -L${libdir} -lparquet Cflags: -I${includedir} Cflags.private: -DPARQUET_STATIC diff --git a/dev/release/verify-apt.sh b/dev/release/verify-apt.sh index 49671f01cc7e8..cbb6d93823b21 100755 --- a/dev/release/verify-apt.sh +++ b/dev/release/verify-apt.sh @@ -166,7 +166,7 @@ pushd build/minimal_build cmake . make -j$(nproc) ./arrow-example -c++ -std=c++17 -o arrow-example example.cc $(pkg-config --cflags --libs arrow) +c++ -o arrow-example example.cc $(pkg-config --cflags --libs arrow) -std=c++17 ./arrow-example popd echo "::endgroup::" diff --git a/dev/release/verify-yum.sh b/dev/release/verify-yum.sh index 55fc0c1735931..a3904169bbf61 100755 --- a/dev/release/verify-yum.sh +++ b/dev/release/verify-yum.sh @@ -211,7 +211,7 @@ pushd build/minimal_build ${cmake_command} . make -j$(nproc) ./arrow-example -c++ -std=c++17 -o arrow-example example.cc $(pkg-config --cflags --libs arrow) +c++ -o arrow-example example.cc $(pkg-config --cflags --libs arrow) -std=c++17 ./arrow-example popd echo "::endgroup::" diff --git a/dev/tasks/linux-packages/apache-arrow/debian/control.in b/dev/tasks/linux-packages/apache-arrow/debian/control.in index 6b161ddef5d67..8c1bab8d058da 100644 --- a/dev/tasks/linux-packages/apache-arrow/debian/control.in +++ b/dev/tasks/linux-packages/apache-arrow/debian/control.in @@ -141,16 +141,12 @@ Depends: libarrow1400 (= ${binary:Version}), libbrotli-dev, libbz2-dev, - libc-ares-dev, libcurl4-openssl-dev, -@USE_SYSTEM_GRPC@ libgrpc++-dev, liblz4-dev, -@USE_SYSTEM_PROTOBUF@ libprotobuf-dev, -@USE_SYSTEM_PROTOBUF@ libprotoc-dev, + libc-ares-dev, libre2-dev, libsnappy-dev, libssl-dev, - libthrift-dev, libutf8proc-dev, libzstd-dev, nlohmann-json-dev | nlohmann-json3-dev, @@ -204,7 +200,11 @@ Multi-Arch: same Depends: ${misc:Depends}, libarrow-dev (= ${binary:Version}), - libarrow-flight1400 (= ${binary:Version}) + libarrow-flight1400 (= ${binary:Version}), + libc-ares-dev, +@USE_SYSTEM_GRPC@ libgrpc++-dev, +@USE_SYSTEM_PROTOBUF@ libprotobuf-dev, +@USE_SYSTEM_PROTOBUF@ libprotoc-dev Description: Apache Arrow is a data processing library for analysis . This package provides C++ header files for Flight RPC system. @@ -280,7 +280,8 @@ Multi-Arch: same Depends: ${misc:Depends}, libarrow-dev (= ${binary:Version}), - libparquet1400 (= ${binary:Version}) + libparquet1400 (= ${binary:Version}), + libthrift-dev Description: Apache Parquet is a columnar storage format . This package provides C++ header files. diff --git a/dev/tasks/linux-packages/apache-arrow/yum/arrow.spec.in b/dev/tasks/linux-packages/apache-arrow/yum/arrow.spec.in index 8fe0313338030..6a87e19cd3091 100644 --- a/dev/tasks/linux-packages/apache-arrow/yum/arrow.spec.in +++ b/dev/tasks/linux-packages/apache-arrow/yum/arrow.spec.in @@ -273,14 +273,7 @@ License: Apache-2.0 Requires: %{name}%{major_version}-libs = %{version}-%{release} Requires: brotli-devel Requires: bzip2-devel -%if %{use_flight} -Requires: c-ares-devel -%endif Requires: curl-devel -%if %{have_grpc} -Requires: grpc-devel -Requires: grpc-plugins -%endif %if %{use_gcs} Requires: json-devel %endif @@ -413,6 +406,11 @@ Summary: Libraries and header files for Apache Arrow Flight. License: Apache-2.0 Requires: %{name}%{major_version}-flight-libs = %{version}-%{release} Requires: %{name}-devel = %{version}-%{release} +Requires: c-ares-devel +%if %{have_grpc} +Requires: grpc-devel +Requires: grpc-plugins +%endif %description flight-devel Libraries and header files for Apache Arrow Flight.