diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index ac7067c0d6cf..2dff5674bc3f 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -659,6 +659,23 @@ set(ARROW_SHARED_INSTALL_INTERFACE_LIBS) set(ARROW_STATIC_LINK_LIBS arrow::flatbuffers arrow::hadoop) set(ARROW_STATIC_INSTALL_INTERFACE_LIBS) +# We must use google-cloud-cpp::storage first. If +# google-cloud-cpp::storage depends on bundled Abseil, bundled Abseil +# and system Abseil may be mixed. +# +# For example, if Boost::headers is used before +# google-cloud-cpp::storage AND Boost::headers has +# -I/opt/homebrew/include AND /opt/homebrew/include/absl/ exists, +# /opt/homebrew/include/absl/**/*.h are used instead of .h provided by +# bundled Abseil. +if(ARROW_GCS) + list(APPEND ARROW_SHARED_LINK_LIBS google-cloud-cpp::storage) + list(APPEND ARROW_STATIC_LINK_LIBS google-cloud-cpp::storage) + if(google_cloud_cpp_storage_SOURCE STREQUAL "SYSTEM") + list(APPEND ARROW_STATIC_INSTALL_INTERFACE_LIBS google-cloud-cpp::storage) + endif() +endif() + if(ARROW_USE_BOOST) list(APPEND ARROW_SHARED_LINK_LIBS Boost::headers) list(APPEND ARROW_STATIC_LINK_LIBS Boost::headers) @@ -725,14 +742,6 @@ if(ARROW_ORC) endif() endif() -if(ARROW_GCS) - list(APPEND ARROW_SHARED_LINK_LIBS google-cloud-cpp::storage) - list(APPEND ARROW_STATIC_LINK_LIBS google-cloud-cpp::storage) - if(google_cloud_cpp_storage_SOURCE STREQUAL "SYSTEM") - list(APPEND ARROW_STATIC_INSTALL_INTERFACE_LIBS google-cloud-cpp::storage) - endif() -endif() - if(ARROW_USE_GLOG) list(APPEND ARROW_SHARED_LINK_LIBS glog::glog) list(APPEND ARROW_STATIC_LINK_LIBS glog::glog) diff --git a/cpp/src/arrow/flight/CMakeLists.txt b/cpp/src/arrow/flight/CMakeLists.txt index 42dafdf49696..2a88e5f8ec76 100644 --- a/cpp/src/arrow/flight/CMakeLists.txt +++ b/cpp/src/arrow/flight/CMakeLists.txt @@ -238,13 +238,19 @@ add_arrow_lib(arrow_flight SHARED_LINK_FLAGS ${ARROW_VERSION_SCRIPT_FLAGS} # Defined in cpp/arrow/CMakeLists.txt SHARED_LINK_LIBS - arrow_shared + # We must use gRPC::grpc++ first. If gRPC::grpc++ + # depends on bundled Abseil, bundled Abseil and system + # Abseil may be mixed. + # + # See also a comment for "if(ARROW_GCS)" in + # cpp/CMakeLists.txt. ${ARROW_FLIGHT_LINK_LIBS} + arrow_shared SHARED_INSTALL_INTERFACE_LIBS Arrow::arrow_shared STATIC_LINK_LIBS - arrow_static ${ARROW_FLIGHT_LINK_LIBS} + arrow_static STATIC_INSTALL_INTERFACE_LIBS Arrow::arrow_static)