@@ -3189,41 +3189,49 @@ function(build_grpc)
31893189 TRUE
31903190 PARENT_SCOPE)
31913191
3192- set (_gRPC_PROTOBUF_LIBRARIES
3193- "protobuf::libprotobuf"
3194- CACHE STRING "" FORCE )
3192+ fetchcontent_declare(grpc
3193+ URL ${GRPC_SOURCE_URL}
3194+ URL_HASH "SHA256= ${ARROW_GRPC_BUILD_SHA256_CHECKSUM} " )
31953195
3196- set (_gRPC_PROTOBUF_PROTOC_LIBRARIES
3197- "protobuf::libprotoc"
3198- CACHE STRING "" FORCE)
3196+ prepare_fetchcontent()
31993197
3200- set (_gRPC_PROTOBUF_PROTOC_EXECUTABLE
3201- "$<TARGET_FILE:protobuf::protoc>"
3202- CACHE STRING "" FORCE)
3198+ if (PROTOBUF_VENDORED)
3199+ set (_gRPC_PROTOBUF_LIBRARIES
3200+ "protobuf::libprotobuf"
3201+ CACHE STRING "" FORCE)
32033202
3204- # Get include directory from protobuf source (not the target property with generator expressions)
3205- # gRPC needs this at configure time for add_custom_command, so we can't use generator expressions
3206- # protobuf_SOURCE_DIR points to cmake/ subdirectory due to SOURCE_SUBDIR, so go up one level
3207- get_filename_component (_protobuf_root_dir "${protobuf_SOURCE_DIR} " DIRECTORY )
3208- set (_gRPC_PROTOBUF_WELLKNOWN_INCLUDE_DIR
3209- "${_protobuf_root_dir} /src"
3210- CACHE STRING "" FORCE)
3203+ set (_gRPC_PROTOBUF_PROTOC_LIBRARIES
3204+ "protobuf::libprotoc"
3205+ CACHE STRING "" FORCE)
32113206
3212- # For c-ares and RE2, we've already built them via FetchContent and targets exist.
3213- # Set provider to "none" to skip gRPC's dependency resolution, and set library variables directly.
3214- set (gRPC_CARES_PROVIDER
3215- "none"
3216- CACHE STRING "" FORCE)
3217- set (_gRPC_CARES_LIBRARIES
3218- "c-ares::cares"
3219- CACHE STRING "" FORCE)
3207+ set (_gRPC_PROTOBUF_PROTOC_EXECUTABLE
3208+ "$<TARGET_FILE:protobuf::protoc>"
3209+ CACHE STRING "" FORCE)
32203210
3221- set (gRPC_RE2_PROVIDER
3222- "none"
3223- CACHE STRING "" FORCE)
3224- set (_gRPC_RE2_LIBRARIES
3225- "re2::re2"
3226- CACHE STRING "" FORCE)
3211+ # gRPC needs this at configure time for add_custom_command.
3212+ get_filename_component (_protobuf_root_dir "${protobuf_SOURCE_DIR} " DIRECTORY )
3213+ set (_gRPC_PROTOBUF_WELLKNOWN_INCLUDE_DIR
3214+ "${_protobuf_root_dir} /src"
3215+ CACHE STRING "" FORCE)
3216+ endif ()
3217+
3218+ if (CARES_VENDORED)
3219+ set (gRPC_CARES_PROVIDER
3220+ "none"
3221+ CACHE STRING "" FORCE)
3222+ set (_gRPC_CARES_LIBRARIES
3223+ "c-ares::cares"
3224+ CACHE STRING "" FORCE)
3225+ endif ()
3226+
3227+ if (RE2_VENDORED)
3228+ set (gRPC_RE2_PROVIDER
3229+ "none"
3230+ CACHE STRING "" FORCE)
3231+ set (_gRPC_RE2_LIBRARIES
3232+ "re2::re2"
3233+ CACHE STRING "" FORCE)
3234+ endif ()
32273235 set (gRPC_SSL_PROVIDER
32283236 "package"
32293237 CACHE STRING "" FORCE)
@@ -3240,11 +3248,7 @@ function(build_grpc)
32403248 string (APPEND CMAKE_CXX_FLAGS
32413249 " -Wno-attributes -Wno-format-security -Wno-unknown-warning-option" )
32423250 endif ()
3243- fetchcontent_declare(grpc
3244- URL ${GRPC_SOURCE_URL}
3245- URL_HASH "SHA256=${ARROW_GRPC_BUILD_SHA256_CHECKSUM} " )
32463251
3247- prepare_fetchcontent()
32483252 fetchcontent_makeavailable(grpc)
32493253
32503254 # FetchContent builds gRPC libraries without gRPC:: prefix.
0 commit comments