kou commented on code in PR #48964:
URL: https://github.com/apache/arrow/pull/48964#discussion_r3019905356
##########
cpp/cmake_modules/ThirdpartyToolchain.cmake:
##########
@@ -3380,25 +3368,150 @@ if(ARROW_WITH_NLOHMANN_JSON)
message(STATUS "Found nlohmann_json headers: ${nlohmann_json_INCLUDE_DIR}")
endif()
+function(build_opentelemetry)
+ list(APPEND CMAKE_MESSAGE_INDENT "OpenTelemetry: ")
+ message(STATUS "Building OpenTelemetry from source using FetchContent")
+
+ if(Protobuf_VERSION VERSION_GREATER_EQUAL 3.22)
+ message(FATAL_ERROR "GH-36013: Can't use bundled OpenTelemetry with
Protobuf 3.22 or later. "
+ "Protobuf is version ${Protobuf_VERSION}")
+ endif()
+
+ set(OPENTELEMETRY_VENDORED
+ TRUE
+ PARENT_SCOPE)
+
+ fetchcontent_declare(opentelemetry_proto
+ ${FC_DECLARE_COMMON_OPTIONS}
+ URL ${OPENTELEMETRY_PROTO_SOURCE_URL}
+ URL_HASH
"SHA256=${ARROW_OPENTELEMETRY_PROTO_BUILD_SHA256_CHECKSUM}"
+ )
+
+ fetchcontent_makeavailable(opentelemetry_proto)
+
+ fetchcontent_declare(opentelemetry_cpp
+ ${FC_DECLARE_COMMON_OPTIONS}
+ URL ${OPENTELEMETRY_SOURCE_URL}
+ URL_HASH
"SHA256=${ARROW_OPENTELEMETRY_BUILD_SHA256_CHECKSUM}")
+
+ prepare_fetchcontent()
+
+ # Unity build causes symbol redefinition errors in protobuf-generated code
+ set(CMAKE_UNITY_BUILD FALSE)
+ set(OTELCPP_PROTO_PATH "${opentelemetry_proto_SOURCE_DIR}")
+ set(WITH_EXAMPLES OFF)
+ set(WITH_OTLP_HTTP ON)
+ set(WITH_OTLP_GRPC OFF)
+ set(WITH_FUNC_TESTS OFF)
+ # These options are slated for removal in v1.14 and their features are
deemed stable
+ # as of v1.13. However, setting their corresponding ENABLE_* macros in
headers seems
+ # finicky - resulting in build failures or ABI-related runtime errors during
HTTP
+ # client initialization. There may still be a solution, but we disable them
for now.
+ set(WITH_OTLP_HTTP_SSL_PREVIEW OFF)
+ set(WITH_OTLP_HTTP_SSL_TLS_PREVIEW OFF)
+
+ fetchcontent_makeavailable(opentelemetry_cpp)
+
+ if(CMAKE_VERSION VERSION_LESS 3.28)
+ set_property(DIRECTORY ${opentelemetry_cpp_SOURCE_DIR} PROPERTY
EXCLUDE_FROM_ALL TRUE)
+ endif()
+
+ # Remove unused directories to save build directory storage
+ file(REMOVE_RECURSE "${opentelemetry_cpp_SOURCE_DIR}/ci")
+
+ # OpenTelemetry creates its own targets. We need to add them to bundled
static libs.
+ # The targets created by OpenTelemetry's CMakeLists.txt use the
opentelemetry:: namespace.
+ # List of libraries that we actually need and want to bundle.
+ set(_OPENTELEMETRY_BUNDLED_LIBS
+ opentelemetry-cpp::common
+ opentelemetry-cpp::http_client_curl
+ opentelemetry-cpp::logs
+ opentelemetry-cpp::ostream_log_record_exporter
+ opentelemetry-cpp::ostream_span_exporter
+ opentelemetry-cpp::otlp_http_client
+ opentelemetry-cpp::otlp_http_log_record_exporter
+ opentelemetry-cpp::otlp_http_exporter
+ opentelemetry-cpp::otlp_recordable
+ opentelemetry-cpp::proto
+ opentelemetry-cpp::resources
+ opentelemetry-cpp::trace
+ opentelemetry-cpp::version)
+
+ list(APPEND ARROW_BUNDLED_STATIC_LIBS ${_OPENTELEMETRY_BUNDLED_LIBS})
+ set(ARROW_BUNDLED_STATIC_LIBS
+ "${ARROW_BUNDLED_STATIC_LIBS}"
+ PARENT_SCOPE)
+
+ list(POP_BACK CMAKE_MESSAGE_INDENT)
+endfunction()
+
+if(ARROW_WITH_OPENTELEMETRY)
+ if(NOT ARROW_ENABLE_THREADING)
+ message(FATAL_ERROR "Can't use OpenTelemetry with
ARROW_ENABLE_THREADING=OFF")
+ endif()
+
+ # cURL is required whether we build from source or use an existing
installation
+ # (OTel's cmake files do not call find_curl for you)
+ find_curl()
+ resolve_dependency(opentelemetry-cpp)
+ set(ARROW_OPENTELEMETRY_LIBS
+ opentelemetry-cpp::trace
+ opentelemetry-cpp::logs
+ opentelemetry-cpp::otlp_http_log_record_exporter
+ opentelemetry-cpp::ostream_log_record_exporter
+ opentelemetry-cpp::ostream_span_exporter
+ opentelemetry-cpp::otlp_http_exporter)
+ get_target_property(OPENTELEMETRY_INCLUDE_DIR opentelemetry-cpp::api
+ INTERFACE_INCLUDE_DIRECTORIES)
+ message(STATUS "Found OpenTelemetry headers: ${OPENTELEMETRY_INCLUDE_DIR}")
+endif()
+
+# ----------------------------------------------------------------------
+# GCS and dependencies
+
function(build_google_cloud_cpp_storage)
list(APPEND CMAKE_MESSAGE_INDENT "google-cloud-cpp: ")
message(STATUS "Building google-cloud-cpp from source using FetchContent")
set(GOOGLE_CLOUD_CPP_VENDORED
TRUE
PARENT_SCOPE)
- # List of dependencies taken from
https://github.com/googleapis/google-cloud-cpp/blob/main/doc/packaging.md
- build_crc32c_once()
+ # Workaround missing BCRYPT_RSA_ALG_HANDLE macro in older MinGW-w64 headers.
+ # google-cloud-cpp v3+ uses it without guards in sign_using_sha256.cc.
+ set(GOOGLE_CLOUD_CPP_PATCH_COMMAND)
+ if(MINGW)
Review Comment:
Could you also check MinGW-w64 version? `CMAKE_CXX_COMPILER_VERSION` may not
be MinGW-w64 version but I think that it's good enough.
##########
cpp/cmake_modules/ThirdpartyToolchain.cmake:
##########
@@ -1890,12 +1882,66 @@ if(ARROW_WITH_THRIFT)
list(GET Thrift_VERSION_LIST 2 Thrift_VERSION_PATCH)
endif()
+# ----------------------------------------------------------------------
+# Abseil defined here so it can be called from build_protobuf()
+
+function(build_absl)
+ list(APPEND CMAKE_MESSAGE_INDENT "ABSL: ")
+ message(STATUS "Building Abseil from source using FetchContent")
+ set(ABSL_VENDORED
+ TRUE
+ PARENT_SCOPE)
+
+ if(CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION
VERSION_GREATER_EQUAL 13.0)
+ string(APPEND CMAKE_CXX_FLAGS " -include stdint.h")
+ endif()
+
+ fetchcontent_declare(absl
+ ${FC_DECLARE_COMMON_OPTIONS} OVERRIDE_FIND_PACKAGE
+ URL ${ABSL_SOURCE_URL}
+ URL_HASH "SHA256=${ARROW_ABSL_BUILD_SHA256_CHECKSUM}")
+
+ prepare_fetchcontent()
+
+ # Unity build causes symbol redefinition errors (e.g. kDigits in
+ # time_zone_fixed.cc and time_zone_posix.cc anonymous namespaces).
+ set(CMAKE_UNITY_BUILD OFF)
+ # We have to enable Abseil install to add Abseil targets to an export set.
+ # But we don't install Abseil by EXCLUDE_FROM_ALL.
+ set(ABSL_ENABLE_INSTALL ON)
Review Comment:
Oh. Could you add a comment that this is needed for bundled protobuf?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]