Skip to content

Conversation

@raulcd
Copy link
Member

@raulcd raulcd commented Dec 3, 2025

Rationale for this change

As a follow up of requiring a minimum CMake version >= 3.25 we discussed moving our dependencies from ExternalProject to FetchContent. This can simplify our third party dependency management.

What changes are included in this PR?

The general change is moving CRC32C from ExternalProject to FetchContent.

We will be able to clean up installation once google-cloud-cpp is also migated.

Are these changes tested?

Yes, the changes are tested locally and on CI.

Are there any user-facing changes?

No

@raulcd
Copy link
Member Author

raulcd commented Dec 3, 2025

@github-actions crossbow submit -g cpp

@github-actions
Copy link

github-actions bot commented Dec 3, 2025

Revision: e4ed6a0

Submitted crossbow builds: ursacomputing/crossbow @ actions-7215a8e6f9

Task Status
example-cpp-minimal-build-static GitHub Actions
example-cpp-minimal-build-static-system-dependency GitHub Actions
example-cpp-tutorial GitHub Actions
test-build-cpp-fuzz GitHub Actions
test-conda-cpp GitHub Actions
test-conda-cpp-valgrind GitHub Actions
test-cuda-cpp-ubuntu-22.04-cuda-11.7.1 GitHub Actions
test-cuda-cpp-ubuntu-24.04-cuda-13.0.2 GitHub Actions
test-debian-12-cpp-amd64 GitHub Actions
test-debian-12-cpp-i386 GitHub Actions
test-fedora-42-cpp GitHub Actions
test-ubuntu-22.04-cpp GitHub Actions
test-ubuntu-22.04-cpp-20 GitHub Actions
test-ubuntu-22.04-cpp-bundled GitHub Actions
test-ubuntu-22.04-cpp-emscripten GitHub Actions
test-ubuntu-22.04-cpp-no-threading GitHub Actions
test-ubuntu-24.04-cpp GitHub Actions
test-ubuntu-24.04-cpp-bundled-offline GitHub Actions
test-ubuntu-24.04-cpp-gcc-13-bundled GitHub Actions
test-ubuntu-24.04-cpp-gcc-14 GitHub Actions
test-ubuntu-24.04-cpp-minimal-with-formats GitHub Actions
test-ubuntu-24.04-cpp-thread-sanitizer GitHub Actions

@raulcd
Copy link
Member Author

raulcd commented Dec 3, 2025

@github-actions crossbow submit -g r

@raulcd raulcd added the CI: Extra Run extra CI label Dec 3, 2025
@github-actions
Copy link

github-actions bot commented Dec 3, 2025

Revision: e4ed6a0

Submitted crossbow builds: ursacomputing/crossbow @ actions-e9c7382c41

Task Status
r-binary-packages GitHub Actions
r-recheck-most GitHub Actions
test-r-arrow-backwards-compatibility GitHub Actions
test-r-depsource-bundled Azure
test-r-depsource-system GitHub Actions
test-r-dev-duckdb GitHub Actions
test-r-devdocs GitHub Actions
test-r-extra-packages GitHub Actions
test-r-gcc-11 GitHub Actions
test-r-gcc-12 GitHub Actions
test-r-install-local GitHub Actions
test-r-install-local-minsizerel GitHub Actions
test-r-linux-as-cran GitHub Actions
test-r-linux-rchk GitHub Actions
test-r-linux-sanitizers GitHub Actions
test-r-linux-valgrind GitHub Actions
test-r-m1-san GitHub Actions
test-r-macos-as-cran GitHub Actions
test-r-minimal-build Azure
test-r-offline-maximal GitHub Actions
test-r-offline-minimal Azure
test-r-rhub-debian-gcc-devel-lto-latest Azure
test-r-rhub-ubuntu-gcc12-custom-ccache Azure
test-r-rhub-ubuntu-release-latest Azure
test-r-rocker-r-ver-latest Azure
test-r-rstudio-r-base-4.1-focal Azure
test-r-rstudio-r-base-4.2-focal Azure
test-r-ubuntu-22.04 GitHub Actions
test-r-versions GitHub Actions

@raulcd raulcd marked this pull request as ready for review December 3, 2025 14:39
@raulcd raulcd requested a review from kou December 3, 2025 14:39
@raulcd
Copy link
Member Author

raulcd commented Dec 3, 2025

I have continued working on this but I am unsure we can make google-cloud-cpp use FetchContent. This is what I am currently investigating.
The problem is that google-cloud-cpp unconditionally does:
find_package(absl CONFIG REQUIRED)
https://github.com/googleapis/google-cloud-cpp/blob/d6aff236f88b608fd15e423cfe74a04c83b90882/CMakeLists.txt#L221

Abseil at that point is only configured and it tries to load the targets file due to the following on build/_deps/absl-build/abslConfig.cmake:

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

but the abslTargets.cmake file is only generated at install time.

@kou do you have ideas for that? I'd love to get rid of all the manual target definitions for abseil but I am unsure what can we do without patching google-cloud-cpp or keeping it as ExternalProject_Add

@raulcd
Copy link
Member Author

raulcd commented Dec 3, 2025

If I apply a patch like on google-cloud-cpp I am able to bypass the problems:

--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -210,7 +210,11 @@ add_custom_target(google-cloud-cpp-protos)
 add_custom_target(doxygen-docs)
 add_custom_target(all-docfx)

-find_package(absl CONFIG REQUIRED)
+# Allow using absl from FetchContent (targets already exist)
+if(NOT TARGET absl::base)
+  find_package(absl CONFIG REQUIRED)
+endif()
+
 if (GOOGLE_CLOUD_CPP_ENABLE_GRPC)
     find_package(gRPC REQUIRED QUIET)
     # `Protobuf_PROTOC_EXECUTABLE` is pretty standard. It has been in use by
--- a/cmake/IncludeNlohmannJson.cmake
+++ b/cmake/IncludeNlohmannJson.cmake
@@ -15,6 +15,11 @@
 # ~~~

 function (find_nlohmann_json)
+    # Allow using nlohmann_json from FetchContent (target already exists)
+    if(TARGET nlohmann_json::nlohmann_json)
+        return()
+    endif()
+
     find_package(nlohmann_json CONFIG QUIET)
     if (nlohmann_json_FOUND)
         return()

Is not strictly for this PR but wanted to share the full picture as the current PR is basicaly pre-work for the google-cloud-cpp one.

@kou
Copy link
Member

kou commented Dec 4, 2025

Could you try OVERRIDE_FIND_PACKAGE in FetchContent_Declare()?
https://cmake.org/cmake/help/latest/module/FetchContent.html#integrating-with-find-package

@github-actions github-actions bot added awaiting changes Awaiting changes and removed awaiting committer review Awaiting committer review labels Dec 4, 2025
@raulcd
Copy link
Member Author

raulcd commented Dec 4, 2025

Could you try OVERRIDE_FIND_PACKAGE in FetchContent_Declare()? https://cmake.org/cmake/help/latest/module/FetchContent.html#integrating-with-find-package

Thanks a lot @kou, that works as expected locally! that was much easier and better than my patch approach :)

One day I'll finally learn these various CMake options. I've learnt a lot the last couple of years, I had never touched a line of CMake prior to working on Arrow, but things like this show me there's still a lot to learn.

Co-authored-by: Sutou Kouhei <kou@cozmixng.org>
@github-actions github-actions bot added awaiting change review Awaiting change review and removed awaiting changes Awaiting changes labels Dec 4, 2025
@raulcd raulcd requested a review from kou December 4, 2025 11:46
@kou
Copy link
Member

kou commented Dec 4, 2025

Could you push a change you tried? (I think that uses OVERRIDE_FIND_PACKAGE. :-)

@raulcd
Copy link
Member Author

raulcd commented Dec 4, 2025

Could you push a change you tried? (I think that uses OVERRIDE_FIND_PACKAGE. :-)

It does not seem necessary for Crc32c, at least locally, it is for Abseil and nlohmann-json. I have pushed a separate draft PR with all the google-cloud-cpp changes to exercise CI and to show you but I prefer this incremental approach so I can tackle problems individually.
The draft PR with the full changes is this one (which incorporates both Crc32c and nlohmann-json)

and the specific commit where OVERRIDE_FIND_PACKAGE is required: e24724f

@raulcd
Copy link
Member Author

raulcd commented Dec 4, 2025

Sorry, after some more testing on the mentioned PR it seems it is necessary for some scenarios. I am still fixing a couple of issues on the other PR. I'll add the OVERRIDE_FIND_PACKAGE here.

@kou kou changed the title GH-48315: [C++] Use FetchContent for bundled Crc32c GH-48315: [C++] Use FetchContent for bundled CRC32C Dec 5, 2025
Copy link
Member

@kou kou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Ah, sorry. I misunderstood.

@kou kou merged commit 773848a into apache:main Dec 5, 2025
64 of 66 checks passed
@kou kou removed the awaiting change review Awaiting change review label Dec 5, 2025
@github-actions github-actions bot added the awaiting merge Awaiting merge label Dec 5, 2025
@raulcd raulcd deleted the GH-48315 branch December 5, 2025 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants