From 84386f8f7d6b7ff3bd7570594e84deb9c1262d6e Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Wed, 31 Jul 2024 11:43:05 +0900 Subject: [PATCH] GH-43467: [C++] Add support for the official LZ4 CMake package (#43468) ### Rationale for this change LZ4 1.10.0 provides `LZ4::lz4` but LZ4 1.9.4 provides only `LZ4::lz4_shared` and `LZ4::lz4_static`. So we need to prepare `LZ4::lz4` in our side. ### What changes are included in this PR? Define `LZ4::lz4` by `LZ4::lz4_shared` or `LZ4::lz4_static` if `LZ4::lz4` doesn't exist. ### Are these changes tested? Yes. ### Are there any user-facing changes? Yes. * GitHub Issue: #43467 Authored-by: Sutou Kouhei Signed-off-by: Jacob Wujciak-Jens --- cpp/cmake_modules/Findlz4Alt.cmake | 12 +++++++++--- cpp/cmake_modules/ThirdpartyToolchain.cmake | 5 ++++- .../apache-arrow/apt/debian-bookworm/Dockerfile | 1 + .../apache-arrow/apt/debian-trixie/Dockerfile | 1 + .../apache-arrow/apt/ubuntu-focal/Dockerfile | 1 + .../apache-arrow/apt/ubuntu-jammy/Dockerfile | 1 + .../apache-arrow/apt/ubuntu-noble/Dockerfile | 1 + .../linux-packages/apache-arrow/debian/control.in | 2 ++ dev/tasks/linux-packages/apache-arrow/debian/rules | 4 +++- 9 files changed, 23 insertions(+), 5 deletions(-) diff --git a/cpp/cmake_modules/Findlz4Alt.cmake b/cpp/cmake_modules/Findlz4Alt.cmake index 77a22957f7964..91e735107a954 100644 --- a/cpp/cmake_modules/Findlz4Alt.cmake +++ b/cpp/cmake_modules/Findlz4Alt.cmake @@ -29,9 +29,15 @@ endif() find_package(lz4 ${find_package_args}) if(lz4_FOUND) set(lz4Alt_FOUND TRUE) - # Conan uses lz4::lz4 not LZ4::lz4 - if(NOT TARGET LZ4::lz4 AND TARGET lz4::lz4) - add_library(LZ4::lz4 ALIAS lz4::lz4) + if(NOT TARGET LZ4::lz4) + # Conan uses lz4::lz4 not LZ4::lz4 + if(TARGET lz4::lz4) + add_library(LZ4::lz4 ALIAS lz4::lz4) + elseif(ARROW_LZ4_USE_SHARED) + add_library(LZ4::lz4 ALIAS LZ4::lz4_shared) + else() + add_library(LZ4::lz4 ALIAS LZ4::lz4_static) + endif() endif() return() endif() diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index 8cb3ec83f57db..cf438f9bc7a81 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -4507,9 +4507,12 @@ function(build_orc) OFF CACHE BOOL "" FORCE) get_target_property(LZ4_INCLUDE_DIR LZ4::lz4 INTERFACE_INCLUDE_DIRECTORIES) + if(NOT LZ4_INCLUDE_DIR) + find_path(LZ4_INCLUDE_DIR NAMES lz4.h) + endif() get_filename_component(LZ4_ROOT "${LZ4_INCLUDE_DIR}" DIRECTORY) set(LZ4_HOME - ${LZ4_ROOT} + "${LZ4_ROOT}" CACHE STRING "" FORCE) set(LZ4_LIBRARY LZ4::lz4 diff --git a/dev/tasks/linux-packages/apache-arrow/apt/debian-bookworm/Dockerfile b/dev/tasks/linux-packages/apache-arrow/apt/debian-bookworm/Dockerfile index b38ee72d68c75..ec3bf7751d2d7 100644 --- a/dev/tasks/linux-packages/apache-arrow/apt/debian-bookworm/Dockerfile +++ b/dev/tasks/linux-packages/apache-arrow/apt/debian-bookworm/Dockerfile @@ -65,6 +65,7 @@ RUN \ libssl-dev \ libthrift-dev \ libutf8proc-dev \ + libxxhash-dev \ libzstd-dev \ llvm-dev \ lsb-release \ diff --git a/dev/tasks/linux-packages/apache-arrow/apt/debian-trixie/Dockerfile b/dev/tasks/linux-packages/apache-arrow/apt/debian-trixie/Dockerfile index 3126c6d3cded0..8f7e5bfc573b3 100644 --- a/dev/tasks/linux-packages/apache-arrow/apt/debian-trixie/Dockerfile +++ b/dev/tasks/linux-packages/apache-arrow/apt/debian-trixie/Dockerfile @@ -66,6 +66,7 @@ RUN \ libssl-dev \ libthrift-dev \ libutf8proc-dev \ + libxxhash-dev \ libzstd-dev \ llvm-dev \ lsb-release \ diff --git a/dev/tasks/linux-packages/apache-arrow/apt/ubuntu-focal/Dockerfile b/dev/tasks/linux-packages/apache-arrow/apt/ubuntu-focal/Dockerfile index fdd0362680c5a..fe783638b6344 100644 --- a/dev/tasks/linux-packages/apache-arrow/apt/ubuntu-focal/Dockerfile +++ b/dev/tasks/linux-packages/apache-arrow/apt/ubuntu-focal/Dockerfile @@ -56,6 +56,7 @@ RUN \ libssl-dev \ libthrift-dev \ libutf8proc-dev \ + libxxhash-dev \ libzstd-dev \ llvm-dev \ lsb-release \ diff --git a/dev/tasks/linux-packages/apache-arrow/apt/ubuntu-jammy/Dockerfile b/dev/tasks/linux-packages/apache-arrow/apt/ubuntu-jammy/Dockerfile index e6718e59b0aba..1d9065d6b2e61 100644 --- a/dev/tasks/linux-packages/apache-arrow/apt/ubuntu-jammy/Dockerfile +++ b/dev/tasks/linux-packages/apache-arrow/apt/ubuntu-jammy/Dockerfile @@ -58,6 +58,7 @@ RUN \ libssl-dev \ libthrift-dev \ libutf8proc-dev \ + libxxhash-dev \ libzstd-dev \ llvm-dev \ lsb-release \ diff --git a/dev/tasks/linux-packages/apache-arrow/apt/ubuntu-noble/Dockerfile b/dev/tasks/linux-packages/apache-arrow/apt/ubuntu-noble/Dockerfile index 87ea2402456b0..f5f5e12f4d560 100644 --- a/dev/tasks/linux-packages/apache-arrow/apt/ubuntu-noble/Dockerfile +++ b/dev/tasks/linux-packages/apache-arrow/apt/ubuntu-noble/Dockerfile @@ -60,6 +60,7 @@ RUN \ libssl-dev \ libthrift-dev \ libutf8proc-dev \ + libxxhash-dev \ libzstd-dev \ llvm-dev \ lsb-release \ diff --git a/dev/tasks/linux-packages/apache-arrow/debian/control.in b/dev/tasks/linux-packages/apache-arrow/debian/control.in index c33e3ac791be1..d249314ac2604 100644 --- a/dev/tasks/linux-packages/apache-arrow/debian/control.in +++ b/dev/tasks/linux-packages/apache-arrow/debian/control.in @@ -27,6 +27,7 @@ Build-Depends: libssl-dev, libthrift-dev, libutf8proc-dev, + libxxhash-dev, libzstd-dev, meson, ninja-build, @@ -151,6 +152,7 @@ Depends: libsnappy-dev, libssl-dev, libutf8proc-dev, + libxxhash-dev, libzstd-dev, nlohmann-json-dev | nlohmann-json3-dev, @USE_SYSTEM_GRPC@ protobuf-compiler-grpc, diff --git a/dev/tasks/linux-packages/apache-arrow/debian/rules b/dev/tasks/linux-packages/apache-arrow/debian/rules index 6c3074ab234e1..40877f44dbe66 100755 --- a/dev/tasks/linux-packages/apache-arrow/debian/rules +++ b/dev/tasks/linux-packages/apache-arrow/debian/rules @@ -107,8 +107,10 @@ override_dh_auto_test: # libarrow.so: avoid failing with "Unknown DWARF DW_OP_172" # libgandiva.so: avoid failing with "Unknown DWARF DW_OP_255" +# libparquet.so: avoid failing with "Unknown DWARF DW_OP_4" # See also: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=949296 override_dh_dwz: dh_dwz \ --exclude=libarrow.so \ - --exclude=libgandiva.so + --exclude=libgandiva.so \ + --exclude=libparquet.so