Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 22 additions & 12 deletions cpp/cmake_modules/BuildUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -176,24 +176,34 @@ function(arrow_create_merged_static_lib output_target)
set(ar_tool ${CMAKE_CXX_COMPILER_AR})
endif()

set(BUNDLE_COMMAND ${ar_tool} -M < ${ar_script_path})
set(ar_script_runner "${CMAKE_CURRENT_BINARY_DIR}/${ARG_NAME}-merge.cmake")
file(WRITE "${ar_script_runner}"
"execute_process(COMMAND \"${ar_tool}\" -M INPUT_FILE \"${ar_script_path}\" RESULT_VARIABLE result)\n"
"if(NOT \"\${result}\" STREQUAL \"0\")\n"
" message(FATAL_ERROR \"Failed to merge ${ARG_NAME}: \${result}\")\n"
"endif()\n")
set(BUNDLE_COMMAND ${CMAKE_COMMAND} -P ${ar_script_runner})
else()
message(FATAL_ERROR "Unknown bundle scenario!")
endif()

add_custom_target(${output_target}_merge ALL
${BUNDLE_COMMAND}
DEPENDS ${ARG_ROOT} ${ARG_TO_MERGE}
BYPRODUCTS ${output_lib_path}
COMMENT "Bundling ${output_lib_path}"
VERBATIM)
set(dummy_source "${CMAKE_CURRENT_BINARY_DIR}/${output_target}.cc")
file(WRITE "${dummy_source}" "void ${output_target}_anchor() {}\n")

message(STATUS "Creating bundled static library target ${output_target} at ${output_lib_path}"
)
add_library(${output_target} STATIC "${dummy_source}")
set_target_properties(${output_target}
PROPERTIES ARCHIVE_OUTPUT_DIRECTORY
"${BUILD_OUTPUT_ROOT_DIRECTORY}" OUTPUT_NAME
"${ARG_NAME}")
set_property(TARGET ${output_target} PROPERTY LINK_DEPENDS "${all_library_paths}")

add_dependencies(${output_target} ${ARG_ROOT} ${ARG_TO_MERGE})

add_library(${output_target} STATIC IMPORTED GLOBAL)
set_target_properties(${output_target} PROPERTIES IMPORTED_LOCATION ${output_lib_path})
add_dependencies(${output_target} ${output_target}_merge)
add_custom_command(TARGET ${output_target}
POST_BUILD
COMMAND ${BUNDLE_COMMAND}
COMMENT "Bundling ${output_lib_path}"
VERBATIM)
endfunction()

function(arrow_install_cmake_package PACKAGE_NAME EXPORT_NAME)
Expand Down
22 changes: 22 additions & 0 deletions cpp/cmake_modules/ThirdpartyToolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4323,6 +4323,28 @@ function(build_awssdk)
endif()
endif()
endforeach()
# Keep platform libraries required by the bundled AWS CRT with the
# aws-c-common target so they are propagated to the bundled archive.
if(TARGET aws-c-common)
if(APPLE)
find_library(CORE_FOUNDATION CoreFoundation REQUIRED)
find_library(NETWORK Network REQUIRED)
find_library(SECURITY Security REQUIRED)
target_link_libraries(aws-c-common INTERFACE "${CORE_FOUNDATION}" "${NETWORK}"
"${SECURITY}")
elseif(WIN32)
target_link_libraries(aws-c-common
INTERFACE "winhttp.lib"
"bcrypt.lib"
"wininet.lib"
"userenv.lib"
"version.lib"
"ncrypt.lib"
"Secur32.lib"
"Shlwapi.lib")
endif()
endif()

list(PREPEND
AWSSDK_LINK_LIBRARIES
aws-cpp-sdk-identity-management
Expand Down
57 changes: 0 additions & 57 deletions cpp/src/arrow/ArrowConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -110,63 +110,6 @@ endif()

include("${CMAKE_CURRENT_LIST_DIR}/ArrowTargets.cmake")

if(TARGET Arrow::arrow_static AND NOT TARGET Arrow::arrow_bundled_dependencies)
add_library(Arrow::arrow_bundled_dependencies STATIC IMPORTED)
get_target_property(arrow_static_configurations Arrow::arrow_static
IMPORTED_CONFIGURATIONS)
foreach(CONFIGURATION ${arrow_static_configurations})
string(TOUPPER "${CONFIGURATION}" CONFIGURATION)
get_target_property(arrow_static_location Arrow::arrow_static
LOCATION_${CONFIGURATION})
get_filename_component(arrow_lib_dir "${arrow_static_location}" DIRECTORY)
set_property(TARGET Arrow::arrow_bundled_dependencies
APPEND
PROPERTY IMPORTED_CONFIGURATIONS ${CONFIGURATION})
set_target_properties(Arrow::arrow_bundled_dependencies
PROPERTIES IMPORTED_LOCATION_${CONFIGURATION}
"${arrow_lib_dir}/${CMAKE_STATIC_LIBRARY_PREFIX}arrow_bundled_dependencies${CMAKE_STATIC_LIBRARY_SUFFIX}"
)
endforeach()

if(ARROW_BUNDLED_STATIC_LIBS)
get_target_property(arrow_bundled_dependencies_link_libs Arrow::arrow_static
INTERFACE_LINK_LIBRARIES)
list(REMOVE_ITEM arrow_bundled_dependencies_link_libs
Arrow::arrow_bundled_dependencies)
target_link_libraries(Arrow::arrow_bundled_dependencies
INTERFACE ${arrow_bundled_dependencies_link_libs})
endif()

# CMP0057: Support new if() IN_LIST operator.
# https://cmake.org/cmake/help/latest/policy/CMP0057.html
cmake_policy(PUSH)
cmake_policy(SET CMP0057 NEW)
if(APPLE AND ("aws-c-common" IN_LIST ARROW_BUNDLED_STATIC_LIBS
OR "absl::time" IN_LIST ARROW_BUNDLED_STATIC_LIBS))
find_library(CORE_FOUNDATION CoreFoundation)
target_link_libraries(Arrow::arrow_bundled_dependencies INTERFACE ${CORE_FOUNDATION})
endif()
if("aws-c-common" IN_LIST ARROW_BUNDLED_STATIC_LIBS)
if(APPLE)
find_library(NETWORK Network)
target_link_libraries(Arrow::arrow_bundled_dependencies INTERFACE ${NETWORK})
find_library(SECURITY Security)
target_link_libraries(Arrow::arrow_bundled_dependencies INTERFACE ${SECURITY})
elseif(WIN32)
target_link_libraries(Arrow::arrow_bundled_dependencies
INTERFACE "winhttp.lib"
"bcrypt.lib"
"wininet.lib"
"userenv.lib"
"version.lib"
"ncrypt.lib"
"Secur32.lib"
"Shlwapi.lib")
endif()
endif()
cmake_policy(POP)
endif()

macro(arrow_keep_backward_compatibility namespace target_base_name)
string(TOUPPER ${target_base_name} target_base_name_upper)

Expand Down
34 changes: 0 additions & 34 deletions cpp/src/arrow/ArrowGcsConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -38,40 +38,6 @@ endif()

include("${CMAKE_CURRENT_LIST_DIR}/ArrowGcsTargets.cmake")

if(TARGET ArrowGcs::arrow_gcs_static
AND ARROW_GCS_BUNDLED_STATIC_LIBS
AND NOT TARGET ArrowGcs::arrow_gcs_bundled_dependencies)
add_library(ArrowGcs::arrow_gcs_bundled_dependencies STATIC IMPORTED)
get_target_property(arrow_gcs_bundled_dependencies_link_libs ArrowGcs::arrow_gcs_static
INTERFACE_LINK_LIBRARIES)
list(REMOVE_ITEM arrow_gcs_bundled_dependencies_link_libs
ArrowGcs::arrow_gcs_bundled_dependencies Arrow::arrow_static)
if("@absl_SOURCE@" STREQUAL "BUNDLED")
list(APPEND arrow_gcs_bundled_dependencies_link_libs
Arrow::arrow_bundled_dependencies)
endif()
if(NOT WIN32)
list(APPEND arrow_gcs_bundled_dependencies_link_libs OpenSSL::SSL OpenSSL::Crypto)
endif()
target_link_libraries(ArrowGcs::arrow_gcs_bundled_dependencies
INTERFACE ${arrow_gcs_bundled_dependencies_link_libs})
get_target_property(arrow_gcs_static_configurations ArrowGcs::arrow_gcs_static
IMPORTED_CONFIGURATIONS)
foreach(CONFIGURATION ${arrow_gcs_static_configurations})
string(TOUPPER "${CONFIGURATION}" CONFIGURATION)
get_target_property(arrow_gcs_static_location ArrowGcs::arrow_gcs_static
IMPORTED_LOCATION_${CONFIGURATION})
get_filename_component(arrow_gcs_lib_dir "${arrow_gcs_static_location}" DIRECTORY)
set_property(TARGET ArrowGcs::arrow_gcs_bundled_dependencies
APPEND
PROPERTY IMPORTED_CONFIGURATIONS ${CONFIGURATION})
set_target_properties(ArrowGcs::arrow_gcs_bundled_dependencies
PROPERTIES IMPORTED_LOCATION_${CONFIGURATION}
"${arrow_gcs_lib_dir}/${CMAKE_STATIC_LIBRARY_PREFIX}arrow_gcs_bundled_dependencies${CMAKE_STATIC_LIBRARY_SUFFIX}"
)
endforeach()
endif()

arrow_keep_backward_compatibility(ArrowGcs arrow_gcs)

check_required_components(ArrowGcs)
Expand Down
89 changes: 79 additions & 10 deletions cpp/src/arrow/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -980,10 +980,9 @@ if(ARROW_FILESYSTEM)
${_FIRST_GCS_LIB}
TO_MERGE
${_OTHER_GCS_LIBS})
get_target_property(arrow_gcs_bundled_dependencies_path
arrow_gcs_bundled_dependencies IMPORTED_LOCATION)
install(FILES ${arrow_gcs_bundled_dependencies_path} ${INSTALL_IS_OPTIONAL}
DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(TARGETS arrow_gcs_bundled_dependencies ${INSTALL_IS_OPTIONAL}
EXPORT arrow_gcs_targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
string(PREPEND ARROW_GCS_PC_LIBS_PRIVATE " -larrow_gcs_bundled_dependencies")
# Resolve bundled Abseil after SDK
list(PREPEND ARROW_GCS_STATIC_INSTALL_INTERFACE_LIBS
Expand Down Expand Up @@ -1051,6 +1050,56 @@ if(ARROW_FILESYSTEM)
set(ARROW_GCS_PC_LIBS "")
set(ARROW_GCS_PC_REQUIRES "")
endif()
if(ARROW_BUILD_STATIC AND ARROW_GCS_BUNDLED_STATIC_LIBS)
set(_ARROW_GCS_BUNDLED_DEPENDENCIES_LINK_LIBS)
foreach(_bundled_lib IN LISTS ARROW_GCS_BUNDLED_STATIC_LIBS)
if(TARGET ${_bundled_lib})
get_target_property(_bundled_lib_link_libraries ${_bundled_lib}
INTERFACE_LINK_LIBRARIES)
if(_bundled_lib_link_libraries)
list(APPEND _ARROW_GCS_BUNDLED_DEPENDENCIES_LINK_LIBS
${_bundled_lib_link_libraries})
endif()
endif()
endforeach()

foreach(_bundled_lib IN LISTS ARROW_GCS_BUNDLED_STATIC_LIBS)
list(REMOVE_ITEM _ARROW_GCS_BUNDLED_DEPENDENCIES_LINK_LIBS ${_bundled_lib})
endforeach()

if(absl_SOURCE STREQUAL "BUNDLED")
list(FILTER
_ARROW_GCS_BUNDLED_DEPENDENCIES_LINK_LIBS
EXCLUDE
REGEX
"^absl::")
list(APPEND _ARROW_GCS_BUNDLED_DEPENDENCIES_LINK_LIBS
Arrow::arrow_bundled_dependencies)
endif()

if(NOT WIN32)
list(APPEND ARROW_GCS_SYSTEM_DEPENDENCIES OpenSSL)
list(APPEND _ARROW_GCS_BUNDLED_DEPENDENCIES_LINK_LIBS OpenSSL::SSL
OpenSSL::Crypto)
endif()

# nlohmann_json is header-only and only needed to compile
# google-cloud-cpp (bundled or system), not to link against it.
list(FILTER
_ARROW_GCS_BUNDLED_DEPENDENCIES_LINK_LIBS
EXCLUDE
REGEX
"nlohmann_json")

list(REMOVE_DUPLICATES _ARROW_GCS_BUNDLED_DEPENDENCIES_LINK_LIBS)

if(_ARROW_GCS_BUNDLED_DEPENDENCIES_LINK_LIBS)
target_link_libraries(arrow_gcs_bundled_dependencies
INTERFACE "$<INSTALL_INTERFACE:${_ARROW_GCS_BUNDLED_DEPENDENCIES_LINK_LIBS}>"
)
endif()
endif()

add_arrow_lib(arrow_gcs
CMAKE_PACKAGE_NAME
ArrowGcs
Expand Down Expand Up @@ -1236,14 +1285,34 @@ if(ARROW_BUILD_BUNDLED_DEPENDENCIES)
${_FIRST_LIB}
TO_MERGE
${_OTHER_LIBS})
# We can't use install(TARGETS) here because
# arrow_bundled_dependencies is an IMPORTED library.
get_target_property(arrow_bundled_dependencies_path arrow_bundled_dependencies
IMPORTED_LOCATION)
install(FILES ${arrow_bundled_dependencies_path} ${INSTALL_IS_OPTIONAL}
DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(TARGETS arrow_bundled_dependencies ${INSTALL_IS_OPTIONAL}
EXPORT arrow_targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
string(PREPEND ARROW_PC_LIBS_PRIVATE " -larrow_bundled_dependencies")
list(INSERT ARROW_STATIC_INSTALL_INTERFACE_LIBS 0 "Arrow::arrow_bundled_dependencies")

# Propagate only the external link requirements of libraries merged into
# arrow_bundled_dependencies.
set(_ARROW_BUNDLED_DEPENDENCIES_LINK_LIBS)
foreach(_bundled_lib IN LISTS ARROW_BUNDLED_STATIC_LIBS)
if(TARGET ${_bundled_lib})
get_target_property(_bundled_lib_link_libraries ${_bundled_lib}
INTERFACE_LINK_LIBRARIES)
if(_bundled_lib_link_libraries)
list(APPEND _ARROW_BUNDLED_DEPENDENCIES_LINK_LIBS ${_bundled_lib_link_libraries})
endif()
endif()
endforeach()
foreach(_bundled_lib IN LISTS ARROW_BUNDLED_STATIC_LIBS)
list(REMOVE_ITEM _ARROW_BUNDLED_DEPENDENCIES_LINK_LIBS ${_bundled_lib})
endforeach()
list(REMOVE_DUPLICATES _ARROW_BUNDLED_DEPENDENCIES_LINK_LIBS)
if(_ARROW_BUNDLED_DEPENDENCIES_LINK_LIBS)
target_link_libraries(arrow_bundled_dependencies
INTERFACE "$<INSTALL_INTERFACE:${_ARROW_BUNDLED_DEPENDENCIES_LINK_LIBS}>"
)
endif()

endif()

if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
Expand Down
Loading