This is an automated email from the ASF dual-hosted git repository.

brycemecum pushed a commit to branch maint-18.1.0
in repository https://gitbox.apache.org/repos/asf/arrow.git

commit 925c96528dfc9fc76f65b6a8f27662ba27b7f72c
Author: Sutou Kouhei <[email protected]>
AuthorDate: Wed Oct 23 14:04:57 2024 +0900

    GH-44448: [C++] Add support for overwriting grpc_cpp_plugin path for 
cross-compiling (#44507)
    
    ### Rationale for this change
    
    We can't use `find_package(gRPC)` and `gRPC::grpc_cpp_plugin` for 
cross-compiling because it's for host. We need `grpc_cpp_plugin` for target in 
cross-compiling.
    
    ### What changes are included in this PR?
    
    Add `ARROW_GRPC_CPP_PLUGIN` CMake option that overwrites 
`gRPC::grpc_cpp_plugin` path found by `find_package(gRPC)`.
    
    ### Are these changes tested?
    
    Yes.
    
    https://github.com/conda-forge/arrow-cpp-feedstock/pull/1432
    
    ### Are there any user-facing changes?
    
    Yes.
    * GitHub Issue: #44448
    
    Authored-by: Sutou Kouhei <[email protected]>
    Signed-off-by: Sutou Kouhei <[email protected]>
---
 cpp/cmake_modules/DefineOptions.cmake       | 5 +++++
 cpp/cmake_modules/ThirdpartyToolchain.cmake | 8 ++++++++
 2 files changed, 13 insertions(+)

diff --git a/cpp/cmake_modules/DefineOptions.cmake 
b/cpp/cmake_modules/DefineOptions.cmake
index d823444cf7..a7bf9e59f8 100644
--- a/cpp/cmake_modules/DefineOptions.cmake
+++ b/cpp/cmake_modules/DefineOptions.cmake
@@ -640,6 +640,11 @@ Always OFF if building binaries" OFF)
                        "Compiler flags to append when pre-compiling Gandiva 
operations"
                        "")
 
+  #----------------------------------------------------------------------
+  set_option_category("Cross compiling")
+
+  define_option_string(ARROW_GRPC_CPP_PLUGIN "grpc_cpp_plugin path to be used" 
"")
+
   #----------------------------------------------------------------------
   set_option_category("Advanced developer")
 
diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake 
b/cpp/cmake_modules/ThirdpartyToolchain.cmake
index db151b4e0f..0b215b5b25 100644
--- a/cpp/cmake_modules/ThirdpartyToolchain.cmake
+++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake
@@ -4223,6 +4223,14 @@ if(ARROW_WITH_GRPC)
       target_link_libraries(gRPC::grpc++ INTERFACE gRPC::grpc_asan_suppressed)
     endif()
   endif()
+
+  if(ARROW_GRPC_CPP_PLUGIN)
+    if(NOT TARGET gRPC::grpc_cpp_plugin)
+      add_executable(gRPC::grpc_cpp_plugin IMPORTED)
+    endif()
+    set_target_properties(gRPC::grpc_cpp_plugin PROPERTIES IMPORTED_LOCATION
+                                                           
${ARROW_GRPC_CPP_PLUGIN})
+  endif()
 endif()
 
 # ----------------------------------------------------------------------

Reply via email to