coryan commented on a change in pull request #8757:
URL: https://github.com/apache/arrow/pull/8757#discussion_r716885521



##########
File path: cpp/cmake_modules/ThirdpartyToolchain.cmake
##########
@@ -2940,6 +3013,190 @@ if(ARROW_S3)
   endif()
 endif()
 
+# ----------------------------------------------------------------------
+# GCS and dependencies
+
+macro(build_google_cloud_cpp)
+  message(STATUS "Building GCPSDK from source")
+  message(STATUS "Only building storage_client component of google-cloud-cpp 
GCP SDK")
+
+  build_absl_once()
+
+  # List of dependencies taken from 
https://github.com/googleapis/google-cloud-cpp/blob/master/doc/packaging.md
+  # Base the arguments to external projects on 
google-cloud-cpp/super/external/*.cmake files
+  # Also check external packages list with `bazel query 
'deps(//google/cloud/storage:storage_client)'`
+
+  # Build crc32c
+  set(CRC32C_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/crc32c_ep-install")
+  set(CRC32C_CMAKE_ARGS
+      -DCRC32C_BUILD_TESTS=OFF
+      -DCRC32C_BUILD_BENCHMARKS=OFF
+      -DCRC32C_USE_GLOG=OFF
+      -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
+      -DCMAKE_CXX_STANDARD=11
+      "-DCMAKE_CXX_FLAGS=${EP_CXX_FLAGS}"
+      -DCMAKE_INSTALL_LIBDIR=lib
+      "-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>")
+  set(CRC32C_BUILD_BYPRODUCTS)
+
+  set(_CRC32C_STATIC_LIBRARY
+      
"${CRC32C_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}crc32c${CMAKE_STATIC_LIBRARY_SUFFIX}"
+  )
+  set(CRC32C_BUILD_BYPRODUCTS ${_CRC32C_STATIC_LIBRARY})
+  set(CRC32C_LIBRARIES crc32c)
+
+  externalproject_add(crc32c_ep
+                      ${EP_LOG_OPTIONS}
+                      INSTALL_DIR ${CRC32C_PREFIX}
+                      URL ${CRC32C_SOURCE_URL}
+                      CMAKE_ARGS ${CRC32C_CMAKE_ARGS}
+                      BUILD_BYPRODUCTS ${CRC32C_BUILD_BYPRODUCTS})
+  add_library(Crc32c::crc32c STATIC IMPORTED)
+  set_target_properties(Crc32c::crc32c
+                        PROPERTIES IMPORTED_LOCATION ${_CRC32C_STATIC_LIBRARY}
+                                   INTERFACE_INCLUDE_DIRECTORIES
+                                   "${CRC32C_INCLUDE}/include")
+  add_dependencies(Crc32c::crc32c crc32c_ep)
+
+  # "Build" nlohmann-json
+  set(NLOHMANN_JSON_PREFIX 
"${CMAKE_CURRENT_BINARY_DIR}/nlohmann_json_ep-install")
+  set(NLOHMANN_JSON_CMAKE_ARGS
+      -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
+      -DCMAKE_CXX_STANDARD=11
+      "-DCMAKE_CXX_FLAGS=${EP_CXX_FLAGS}"
+      -DBUILD_TESTING=OFF
+      "-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>")
+
+  set(NLOHMANN_JSON_BUILD_BYPRODUCTS ${NLOHMANN_JSON_PREFIX}/include/json.hpp)
+
+  externalproject_add(nlohmann_json_ep
+                      ${EP_LOG_OPTIONS}
+                      INSTALL_DIR ${NLOHMANN_JSON_PREFIX}
+                      URL ${NLOHMANN_JSON_SOURCE_URL}
+                      CMAKE_ARGS ${NLOHMANN_JSON_CMAKE_ARGS}
+                      BUILD_BYPRODUCTS ${NLOHMANN_JSON_BUILD_BYPRODUCTS})
+  add_library(nlohmann_json::nlohmann_json INTERFACE IMPORTED)
+  set_target_properties(nlohmann_json::nlohmann_json
+                        PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
+                                   "${NLOHMANN_JSON_PREFIX}/include")
+  add_dependencies(nlohmann_json::nlohmann_json nlohmann_json_ep)
+
+  # Curl is required on all platforms, but building it internally might also 
trip over S3's copy.
+  # For now, force its inclusion from the underlying system or fail.
+  # TODO: make curl a proper (bundled) third party dependency
+  # Also, curl has a dependency on zlib; see this with `bazel query 
'allpaths(//google/cloud/storage:storage_client, @zlib//:zlib)'`
+  find_package(CURL REQUIRED 7.47.0)
+
+  # Build google-cloud-cpp, with only storage_client
+
+  # Inject vendored packages via CMAKE_PREFIX_PATH
+  list(APPEND GCPSDK_PREFIX_PATH_LIST ${ABSL_PREFIX})
+  list(APPEND GCPSDK_PREFIX_PATH_LIST ${CRC32C_PREFIX})
+  list(APPEND GCPSDK_PREFIX_PATH_LIST ${NLOHMANN_JSON_PREFIX})
+  if(CARES_VENDORED)
+    list(APPEND GCPSDK_PREFIX_PATH_LIST ${CARES_PREFIX})
+  endif()
+
+  set(GCPSDK_PREFIX_PATH_LIST_SEP_CHAR "|")
+  list(JOIN GCPSDK_PREFIX_PATH_LIST ${GCPSDK_PREFIX_PATH_LIST_SEP_CHAR}
+       GCPSDK_PREFIX_PATH)
+
+  set(GCPSDK_CXX_FLAGS "${EP_CXX_FLAGS}")
+  # workaround for crc32c not declaring its header interface in its 
Find*.cmake file

Review comment:
       You can avoid this by using crc32c 1.1.1:
   
   
https://github.com/google/crc32c/commit/b377ce46f56823cf38dd7045f4997dd4b5c6d04c




-- 
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]


Reply via email to