diff --git a/ci/scripts/cpp_test.sh b/ci/scripts/cpp_test.sh index 18c301c5fdac..c7cdd859fc33 100755 --- a/ci/scripts/cpp_test.sh +++ b/ci/scripts/cpp_test.sh @@ -146,12 +146,17 @@ if [ "${ARROW_USE_MESON:-OFF}" = "OFF" ] && \ cmake \ -S "${source_dir}/examples/minimal_build" \ -B "${build_dir}/examples/minimal_build" \ + -DARROW_EXAMPLE_S3="${ARROW_S3:-OFF}" \ -DCMAKE_PREFIX_PATH="${CMAKE_PREFIX_PATH}" cmake --build "${build_dir}/examples/minimal_build" pushd "${source_dir}/examples/minimal_build" # PATH= is for Windows. PATH="${CMAKE_INSTALL_PREFIX:-${ARROW_HOME}}/bin:${PATH}" \ "${build_dir}/examples/minimal_build/arrow-example" + # Test static linking with S3 + if [ -e "${build_dir}/examples/minimal_build/arrow-example-s3-static" ]; then + "${build_dir}/examples/minimal_build/arrow-example-s3-static" + fi popd fi diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index 56f781bb7cf6..8f946c984289 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -4332,9 +4332,16 @@ function(build_azure_sdk) endfunction() if(ARROW_WITH_AZURE_SDK) + if(NOT WIN32) + find_curl() + endif() resolve_dependency(Azure REQUIRED_VERSION 1.10.2) set(AZURE_SDK_LINK_LIBRARIES Azure::azure-storage-files-datalake Azure::azure-storage-blobs Azure::azure-identity) + if(AZURE_SDK_VENDORED AND NOT WIN32) + find_package(LibXml2 REQUIRED) + list(APPEND ARROW_SYSTEM_DEPENDENCIES LibXml2) + endif() endif() # ---------------------------------------------------------------------- diff --git a/cpp/examples/minimal_build/CMakeLists.txt b/cpp/examples/minimal_build/CMakeLists.txt index d0a0a1e0a221..ce7e009f0e71 100644 --- a/cpp/examples/minimal_build/CMakeLists.txt +++ b/cpp/examples/minimal_build/CMakeLists.txt @@ -49,3 +49,14 @@ if(ARROW_LINK_SHARED) else() target_link_libraries(arrow-example PRIVATE Arrow::arrow_static) endif() + +option(ARROW_EXAMPLE_S3 "Verify S3 and static linking" OFF) +if(ARROW_EXAMPLE_S3 AND TARGET Arrow::arrow_static) + add_executable(arrow-example-s3-static example.cc) + target_compile_definitions(arrow-example-s3-static PRIVATE ARROW_EXAMPLE_S3) + target_link_libraries(arrow-example-s3-static PRIVATE Arrow::arrow_static) + find_package(ArrowS3 QUIET) + if(TARGET ArrowS3::arrow_s3_static) + target_link_libraries(arrow-example-s3-static PRIVATE ArrowS3::arrow_s3_static) + endif() +endif() diff --git a/cpp/examples/minimal_build/example.cc b/cpp/examples/minimal_build/example.cc index 9bfb9953edca..86f28d70c52a 100644 --- a/cpp/examples/minimal_build/example.cc +++ b/cpp/examples/minimal_build/example.cc @@ -16,6 +16,9 @@ // under the License. #include +#ifdef ARROW_EXAMPLE_S3 +# include +#endif #include #include #include @@ -54,6 +57,12 @@ Status RunMain(int argc, char** argv) { ARROW_RETURN_NOT_OK(batch_writer->WriteTable(*table)); ARROW_RETURN_NOT_OK(batch_writer->Close()); +#ifdef ARROW_EXAMPLE_S3 + std::cerr << "* Verify S3 initializes and finalizes" << std::endl; + ARROW_RETURN_NOT_OK(arrow::fs::EnsureS3Initialized()); + ARROW_RETURN_NOT_OK(arrow::fs::EnsureS3Finalized()); +#endif + return Status::OK(); } diff --git a/cpp/src/arrow/CMakeLists.txt b/cpp/src/arrow/CMakeLists.txt index eead221dbdae..3f3fd3326984 100644 --- a/cpp/src/arrow/CMakeLists.txt +++ b/cpp/src/arrow/CMakeLists.txt @@ -36,6 +36,20 @@ set(ARROW_STATIC_INSTALL_INTERFACE_LIBS) if(ARROW_GCS) if(google_cloud_cpp_storage_SOURCE STREQUAL "SYSTEM") list(APPEND ARROW_STATIC_INSTALL_INTERFACE_LIBS google-cloud-cpp::storage) + elseif(google_cloud_cpp_storage_SOURCE STREQUAL "BUNDLED") + if(UNIX) + list(APPEND ARROW_STATIC_INSTALL_INTERFACE_LIBS CURL::libcurl) + endif() + endif() +endif() + +if(ARROW_AZURE) + if(Azure_SOURCE STREQUAL "SYSTEM") + list(APPEND ARROW_STATIC_INSTALL_INTERFACE_LIBS ${AZURE_SDK_LINK_LIBRARIES}) + elseif(Azure_SOURCE STREQUAL "BUNDLED") + if(UNIX) + list(APPEND ARROW_STATIC_INSTALL_INTERFACE_LIBS CURL::libcurl LibXml2::LibXml2) + endif() endif() endif()