Skip to content

Commit 62bad2d

Browse files
committed
Some more cleaning after initial tests
1 parent 9386a28 commit 62bad2d

File tree

1 file changed

+25
-80
lines changed

1 file changed

+25
-80
lines changed

cpp/cmake_modules/ThirdpartyToolchain.cmake

Lines changed: 25 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -3042,13 +3042,13 @@ function(build_absl)
30423042
prepare_fetchcontent()
30433043

30443044
# We have to enable Abseil install to generate abslConfig.cmake
3045-
# so gRPC can find Abseil through ExternalProject_Add. Our expectation
3046-
# is that this will not be necessary once gRPC supports FetchContent.
3045+
# so google-cloud-cpp can find Abseil through ExternalProject_Add. Our expectation
3046+
# is that this will not be necessary once google-cloud-cpp supports FetchContent.
30473047
set(ABSL_ENABLE_INSTALL ON)
30483048
fetchcontent_makeavailable(absl)
30493049

30503050
# This custom target is required due to a timing issue between FetchContent
3051-
# and the install command below, which is necessary for GRPC to find Abseil
3051+
# and the install command below, which is necessary for google-cloud-cpp to find Abseil
30523052
# due to mixing FetchContent and ExternalProject_Add.
30533053
# Create a target that depends on ALL Abseil libraries that will be installed.
30543054
# This ensures they're all built before we try to install.
@@ -3120,7 +3120,7 @@ function(build_absl)
31203120
absl::time
31213121
absl::time_zone)
31223122

3123-
# gRPC requires Abseil to be installed to a known location.
3123+
# google-cloud-cpp requires Abseil to be installed to a known location.
31243124
# We have to do this in two steps to avoid double installation of Abseil
31253125
# when Arrow is installed.
31263126
# Disable Abseil's install script this target runs after Abseil is built
@@ -3140,7 +3140,7 @@ function(build_absl)
31403140
add_custom_target(absl_install_disabled ALL
31413141
DEPENDS "${absl_BINARY_DIR}/cmake_install.cmake.saved")
31423142

3143-
# Install Abseil to ABSL_PREFIX for gRPC to find.
3143+
# Install Abseil to ABSL_PREFIX for google-cloud-cpp to find.
31443144
# Using the saved original cmake_install.cmake.saved install script
31453145
# for other dependencies to find Abseil.
31463146
add_custom_command(OUTPUT "${ABSL_PREFIX}/.absl_installed"
@@ -3183,21 +3183,12 @@ function(build_grpc)
31833183
PC_PACKAGE_NAMES
31843184
libcares)
31853185

3186-
list(APPEND CMAKE_MESSAGE_INDENT "GRPC: ")
3186+
list(APPEND CMAKE_MESSAGE_INDENT "gRPC: ")
31873187
message(STATUS "Building gRPC from source using FetchContent")
31883188
set(GRPC_VENDORED
31893189
TRUE
31903190
PARENT_SCOPE)
31913191

3192-
set(gRPC_ABSL_PROVIDER
3193-
"none"
3194-
CACHE STRING "" FORCE)
3195-
3196-
# Skip Protobuf provider and set required library variables directly.
3197-
set(gRPC_PROTOBUF_PROVIDER
3198-
"none"
3199-
CACHE STRING "" FORCE)
3200-
32013192
set(_gRPC_PROTOBUF_LIBRARIES
32023193
"protobuf::libprotobuf"
32033194
CACHE STRING "" FORCE)
@@ -3282,8 +3273,7 @@ function(build_grpc)
32823273
OFF
32833274
CACHE BOOL "" FORCE)
32843275

3285-
# Add warning suppression flags for gRPC build
3286-
3276+
# Add warning suppression flags for gRPC build.
32873277
if(NOT MSVC)
32883278
string(APPEND CMAKE_C_FLAGS
32893279
" -Wno-attributes -Wno-format-security -Wno-unknown-warning-option")
@@ -3297,79 +3287,34 @@ function(build_grpc)
32973287
prepare_fetchcontent()
32983288
fetchcontent_makeavailable(grpc)
32993289

3300-
# Create namespace aliases for gRPC targets (these are not created automatically with add_subdirectory)
3301-
# Is there a way to iterate over all those created targets instead of listing them manually?
3302-
if(NOT TARGET gRPC::address_sorting)
3303-
add_library(gRPC::address_sorting ALIAS address_sorting)
3304-
endif()
3305-
3306-
if(NOT TARGET gRPC::gpr)
3307-
add_library(gRPC::gpr ALIAS gpr)
3308-
endif()
3309-
3310-
if(NOT TARGET gRPC::grpc)
3311-
add_library(gRPC::grpc ALIAS grpc)
3312-
endif()
3313-
3314-
if(NOT TARGET gRPC::grpc++)
3315-
add_library(gRPC::grpc++ ALIAS grpc++)
3316-
endif()
3317-
3318-
if(NOT TARGET gRPC::grpc++_alts)
3319-
add_library(gRPC::grpc++_alts ALIAS grpc++_alts)
3320-
endif()
3321-
3322-
if(NOT TARGET gRPC::grpc++_error_details)
3323-
add_library(gRPC::grpc++_error_details ALIAS grpc++_error_details)
3324-
endif()
3325-
3326-
if(NOT TARGET gRPC::grpc++_reflection)
3327-
add_library(gRPC::grpc++_reflection ALIAS grpc++_reflection)
3328-
endif()
3329-
3330-
if(NOT TARGET gRPC::grpc++_unsecure)
3331-
add_library(gRPC::grpc++_unsecure ALIAS grpc++_unsecure)
3332-
endif()
3333-
3334-
if(NOT TARGET gRPC::grpc_unsecure)
3335-
add_library(gRPC::grpc_unsecure ALIAS grpc_unsecure)
3336-
endif()
3290+
# FetchContent builds gRPC libraries without gRPC:: prefix.
3291+
# Create gRPC:: alias targets for consistency.
3292+
set(GRPC_LIBRARY_TARGETS
3293+
address_sorting
3294+
gpr
3295+
grpc
3296+
grpc++
3297+
grpc++_reflection
3298+
upb)
3299+
3300+
foreach(target ${GRPC_LIBRARY_TARGETS})
3301+
if(TARGET ${target} AND NOT TARGET gRPC::${target})
3302+
add_library(gRPC::${target} ALIAS ${target})
3303+
endif()
3304+
endforeach()
33373305

3338-
if(NOT TARGET gRPC::grpc_cpp_plugin AND TARGET grpc_cpp_plugin)
3306+
if(TARGET grpc_cpp_plugin AND NOT TARGET gRPC::grpc_cpp_plugin)
33393307
add_executable(gRPC::grpc_cpp_plugin ALIAS grpc_cpp_plugin)
33403308
endif()
33413309

3342-
if(NOT TARGET gRPC::upb)
3343-
add_library(gRPC::upb ALIAS upb)
3344-
endif()
3345-
3346-
# ar -M rejects with the "libgrpc++.a" filename because "+" is a line
3347-
# continuation character in these scripts, so we have to create a copy of the
3348-
# static lib that we will bundle later
3349-
set(GRPC_STATIC_LIBRARY_GRPCPP_FOR_AR
3350-
"${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}grpcpp${CMAKE_STATIC_LIBRARY_SUFFIX}"
3351-
)
3352-
add_custom_command(OUTPUT ${GRPC_STATIC_LIBRARY_GRPCPP_FOR_AR}
3353-
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:gRPC::grpc++>
3354-
${GRPC_STATIC_LIBRARY_GRPCPP_FOR_AR}
3355-
DEPENDS gRPC::grpc++)
3356-
add_library(gRPC::grpcpp_for_bundling STATIC IMPORTED)
3357-
set_target_properties(gRPC::grpcpp_for_bundling
3358-
PROPERTIES IMPORTED_LOCATION
3359-
"${GRPC_STATIC_LIBRARY_GRPCPP_FOR_AR}")
3360-
3361-
set_source_files_properties("${GRPC_STATIC_LIBRARY_GRPCPP_FOR_AR}" PROPERTIES GENERATED
3362-
TRUE)
3363-
add_custom_target(grpc_copy_grpc++ ALL DEPENDS "${GRPC_STATIC_LIBRARY_GRPCPP_FOR_AR}")
3364-
add_dependencies(gRPC::grpcpp_for_bundling grpc_copy_grpc++)
3365-
33663310
# Add gRPC libraries to bundled static libs.
33673311
list(APPEND
33683312
ARROW_BUNDLED_STATIC_LIBS
33693313
gRPC::address_sorting
33703314
gRPC::gpr
33713315
gRPC::grpc
3372-
gRPC::grpcpp_for_bundling
3316+
gRPC::grpc++
3317+
gRPC::grpc++_reflection
33733318
gRPC::upb)
33743319
set(ARROW_BUNDLED_STATIC_LIBS
33753320
"${ARROW_BUNDLED_STATIC_LIBS}"

0 commit comments

Comments
 (0)