diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index 04f93629d07..ff3617aff1f 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -4405,6 +4405,41 @@ if(ARROW_BUILD_STATIC) AND NOT WIN32) arrow_append_pc_system_library("libxml-2.0" ARROW_LIBXML2_PC "-lxml2") endif() + if(ARROW_GCS + AND google_cloud_cpp_storage_SOURCE STREQUAL "BUNDLED" + AND absl_SOURCE STREQUAL "SYSTEM") + # Bundled google-cloud-cpp needs system Abseil for static linking. + # Abseil .pc files include indirect link dependencies that -labsl_* flags omit + find_package(PkgConfig QUIET) + if(PkgConfig_FOUND) + foreach(ARROW_GCS_ABSL_PC_PACKAGE + absl_base + absl_cord + absl_crc32c + absl_memory + absl_optional + absl_span + absl_str_format + absl_strings + absl_time + absl_variant) + pkg_check_modules(ARROW_GCS_${ARROW_GCS_ABSL_PC_PACKAGE}_PC + ${ARROW_GCS_ABSL_PC_PACKAGE} + NO_CMAKE_PATH + NO_CMAKE_ENVIRONMENT_PATH + QUIET) + if(ARROW_GCS_${ARROW_GCS_ABSL_PC_PACKAGE}_PC_FOUND) + string(APPEND ARROW_PC_REQUIRES_PRIVATE " ${ARROW_GCS_ABSL_PC_PACKAGE}") + else() + message(STATUS "No .pc for ${ARROW_GCS_ABSL_PC_PACKAGE}; " + "static pkg-config metadata may be incomplete. Consider CMake") + endif() + endforeach() + else() + message(STATUS "PkgConfig not available. Skipping Abseil dependencies from arrow.pc" + ) + endif() + endif() endif() # ---------------------------------------------------------------------- diff --git a/cpp/src/arrow/CMakeLists.txt b/cpp/src/arrow/CMakeLists.txt index 36edf50ba94..2582f033f38 100644 --- a/cpp/src/arrow/CMakeLists.txt +++ b/cpp/src/arrow/CMakeLists.txt @@ -38,6 +38,21 @@ if(ARROW_GCS) list(APPEND ARROW_STATIC_INSTALL_INTERFACE_LIBS google-cloud-cpp::storage) elseif(google_cloud_cpp_storage_SOURCE STREQUAL "BUNDLED") list(APPEND ARROW_STATIC_INSTALL_INTERFACE_LIBS CURL::libcurl) + if(absl_SOURCE STREQUAL "SYSTEM") + # Bundled google-cloud-cpp with system Abseil needs these for static consumers. + list(APPEND + ARROW_STATIC_INSTALL_INTERFACE_LIBS + absl::base + absl::cord + absl::crc32c + absl::memory + absl::optional + absl::span + absl::str_format + absl::strings + absl::time + absl::variant) + endif() endif() endif()