Skip to content

Commit 91f6b54

Browse files
committed
Move from macro build_cares to function
1 parent cb903ad commit 91f6b54

File tree

1 file changed

+19
-21
lines changed

1 file changed

+19
-21
lines changed

cpp/cmake_modules/ThirdpartyToolchain.cmake

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2950,32 +2950,30 @@ if(ARROW_WITH_UTF8PROC)
29502950
resolve_dependency(${utf8proc_resolve_dependency_args})
29512951
endif()
29522952

2953-
macro(build_cares)
2953+
function(build_cares)
2954+
list(APPEND CMAKE_MESSAGE_INDENT "c-ares: ")
29542955
message(STATUS "Building c-ares from source using FetchContent")
2955-
set(CARES_VENDORED TRUE)
2956-
set(CARES_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/cares_ep-install")
2957-
2958-
# Configure c-ares options before FetchContent
2959-
set(CARES_SHARED OFF)
2960-
set(CARES_STATIC ON)
2961-
set(CARES_INSTALL ON)
2962-
set(CARES_BUILD_TOOLS OFF)
2963-
set(CARES_BUILD_TESTS OFF)
2956+
set(CARES_VENDORED
2957+
TRUE
2958+
PARENT_SCOPE)
2959+
set(CARES_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/cares_fc-install")
2960+
set(CARES_PREFIX
2961+
"${CARES_PREFIX}"
2962+
PARENT_SCOPE)
29642963

29652964
fetchcontent_declare(cares
29662965
URL ${CARES_SOURCE_URL}
29672966
URL_HASH "SHA256=${ARROW_CARES_BUILD_SHA256_CHECKSUM}")
29682967

29692968
prepare_fetchcontent()
29702969

2971-
set(CMAKE_INSTALL_PREFIX_SAVED "${CMAKE_INSTALL_PREFIX}")
2972-
set(CMAKE_INSTALL_PREFIX "${CARES_PREFIX}")
2970+
set(CARES_SHARED OFF)
2971+
set(CARES_STATIC ON)
2972+
set(CARES_INSTALL ON)
2973+
set(CARES_BUILD_TOOLS OFF)
2974+
set(CARES_BUILD_TESTS OFF)
29732975
fetchcontent_makeavailable(cares)
29742976

2975-
# Restore original install prefix
2976-
set(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX_SAVED}")
2977-
cleanup_fetchcontent()
2978-
29792977
# gRPC requires c-ares to be installed to a known location.
29802978
# We have to do this in two steps to avoid double installation of c-ares
29812979
# when Arrow is installed.
@@ -3011,8 +3009,8 @@ macro(build_cares)
30113009
COMMENT "Installing c-ares to ${CARES_PREFIX} for gRPC"
30123010
VERBATIM)
30133011

3014-
# Make cares_ep depend on the install completion marker
3015-
add_custom_target(cares_ep DEPENDS "${CARES_PREFIX}/.cares_installed")
3012+
# Make cares_fc depend on the install completion marker
3013+
add_custom_target(cares_fc DEPENDS "${CARES_PREFIX}/.cares_installed")
30163014

30173015
if(APPLE)
30183016
# libresolv must be linked from c-ares version 1.16.1
@@ -3021,8 +3019,8 @@ macro(build_cares)
30213019
"${LIBRESOLV_LIBRARY}")
30223020
endif()
30233021

3024-
list(APPEND ARROW_BUNDLED_STATIC_LIBS c-ares::cares)
3025-
endmacro()
3022+
list(POP_BACK CMAKE_MESSAGE_INDENT)
3023+
endfunction()
30263024

30273025
# ----------------------------------------------------------------------
30283026
# Dependencies for Arrow Flight RPC
@@ -3223,7 +3221,7 @@ macro(build_grpc)
32233221
add_dependencies(grpc_dependencies absl_fc)
32243222
endif()
32253223
if(CARES_VENDORED)
3226-
add_dependencies(grpc_dependencies cares_ep)
3224+
add_dependencies(grpc_dependencies cares_fc)
32273225
endif()
32283226

32293227
if(GFLAGS_VENDORED)

0 commit comments

Comments
 (0)