Control: tags -1 patch

Hi, I've tried a PoC patch to build lz4 with CMake.

It is not fully achieved yet because 
it causes a diff for .symbols, that is not intended.

In other words, it must tweak build flags further more.


Here is the outcome of PoC patch:

$ dpkg-deb -c
liblz4-dev_1.9.4-2_amd64.deb 
drwxr-xr-x root/root         0 2024-04-03 02:18 ./
drwxr-xr-x root/root         0 2024-04-03 02:18 ./usr/
drwxr-xr-x root/root         0 2024-04-03 02:18 ./usr/include/
-rw-r--r-- root/root     43263 2022-08-15 22:45 ./usr/include/lz4.h
-rw-r--r-- root/root     32749 2022-08-15 22:45 ./usr/include/lz4frame.h
-rw-r--r-- root/root     20179 2022-08-15 22:45 ./usr/include/lz4hc.h
drwxr-xr-x root/root         0 2024-04-03 02:18 ./usr/lib/
drwxr-xr-x root/root         0 2024-04-03 02:18
./usr/lib/x86_64-linux-gnu/
drwxr-xr-x root/root         0 2024-04-03 02:18
./usr/lib/x86_64-linux-gnu/cmake/
drwxr-xr-x root/root         0 2024-04-03 02:18
./usr/lib/x86_64-linux-gnu/cmake/lz4/
-rw-r--r-- root/root      1315 2024-04-03 02:18
./usr/lib/x86_64-linux-gnu/cmake/lz4/lz4Config.cmake
-rw-r--r-- root/root      2762 2024-04-03 02:18
./usr/lib/x86_64-linux-gnu/cmake/lz4/lz4ConfigVersion.cmake
-rw-r--r-- root/root      1439 2024-04-03 02:18
./usr/lib/x86_64-linux-gnu/cmake/lz4/lz4Targets-relwithdebinfo.cmake
-rw-r--r-- root/root      4737 2024-04-03 02:18
./usr/lib/x86_64-linux-gnu/cmake/lz4/lz4Targets.cmake
-rw-r--r-- root/root    155774 2024-04-03 02:18
./usr/lib/x86_64-linux-gnu/liblz4.a
drwxr-xr-x root/root         0 2024-04-03 02:18
./usr/lib/x86_64-linux-gnu/pkgconfig/
-rw-r--r-- root/root       406 2024-04-03 02:18
./usr/lib/x86_64-linux-gnu/pkgconfig/liblz4.pc
drwxr-xr-x root/root         0 2024-04-03 02:18 ./usr/share/
drwxr-xr-x root/root         0 2024-04-03 02:18 ./usr/share/doc/
drwxr-xr-x root/root         0 2024-04-03 02:18
./usr/share/doc/liblz4-dev/
-rw-r--r-- root/root       857 2024-04-03 02:18
./usr/share/doc/liblz4-dev/changelog.Debian.gz
-rw-r--r-- root/root      3275 2024-04-03 02:18
./usr/share/doc/liblz4-dev/copyright
lrwxrwxrwx root/root         0 2024-04-03 02:18
./usr/lib/x86_64-linux-gnu/liblz4.so -> liblz4.so.1


Anyway, I hope it will help to make it forward.
>From bbd1377d5ffcc2155909a6ce22142bc23612f5e4 Mon Sep 17 00:00:00 2001
From: Kentaro Hayashi <ken...@gmail.com>
Date: Mon, 17 Jun 2024 21:58:30 +0900
Subject: [PATCH] Use CMake to build lz4

It can ship missing lz4Config.cmake for CMake.

Based on kou's debian/rules.

Closes: #1073192
Signed-off-by: Kentaro Hayashi <ken...@gmail.com>
---
 debian/control                         |  2 +-
 debian/liblz4-dev.install              |  1 +
 debian/patches/series                  |  3 +-
 debian/patches/use-system-xxhash.patch | 72 ++++++++++++++++++++++++++
 debian/rules                           | 12 ++---
 5 files changed, 81 insertions(+), 9 deletions(-)
 create mode 100644 debian/patches/use-system-xxhash.patch

diff --git a/debian/control b/debian/control
index 106eaea..87c219d 100644
--- a/debian/control
+++ b/debian/control
@@ -1,7 +1,7 @@
 Source: lz4
 Priority: optional
 Maintainer: Nobuhiro Iwamatsu <iwama...@debian.org>
-Build-Depends: debhelper-compat (= 13), python3:any <!nocheck>
+Build-Depends: debhelper-compat (= 13), python3:any <!nocheck>, cmake (>= 2.8.12), libxxhash-dev, pkgconf
 Standards-Version: 4.6.1
 Section: utils
 Rules-Requires-Root: no
diff --git a/debian/liblz4-dev.install b/debian/liblz4-dev.install
index 76f28fa..ef2e1d7 100644
--- a/debian/liblz4-dev.install
+++ b/debian/liblz4-dev.install
@@ -1,4 +1,5 @@
 usr/include/*
 usr/lib/*/lib*.a
 usr/lib/*/lib*.so
+usr/lib/*/cmake/*
 usr/lib/*/pkgconfig/*
diff --git a/debian/patches/series b/debian/patches/series
index 5a400cd..d763c26 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,2 +1 @@
-0001-Fix-static-link.patch
-0002-Change-optimize-to-O2.patch
+use-system-xxhash.patch
diff --git a/debian/patches/use-system-xxhash.patch b/debian/patches/use-system-xxhash.patch
new file mode 100644
index 0000000..b774fbe
--- /dev/null
+++ b/debian/patches/use-system-xxhash.patch
@@ -0,0 +1,72 @@
+From: Sutou Kouhei <k...@clear-code.com>
+Date: Mon, 17 Jun 2024 22:00:07 +0900
+Subject: Use xxHash in system library
+
+
+Signed-off-by: Kentaro Hayashi <ken...@gmail.com>
+---
+ build/cmake/CMakeLists.txt | 14 +++++++++++---
+ 1 file changed, 11 insertions(+), 3 deletions(-)
+
+diff --git a/build/cmake/CMakeLists.txt b/build/cmake/CMakeLists.txt
+index eb7007b..37b8e03 100644
+--- a/build/cmake/CMakeLists.txt
++++ b/build/cmake/CMakeLists.txt
+@@ -87,7 +87,8 @@ set(LZ4_SOURCES
+   "${LZ4_LIB_SOURCE_DIR}/lz4hc.h"
+   "${LZ4_LIB_SOURCE_DIR}/lz4frame.c"
+   "${LZ4_LIB_SOURCE_DIR}/lz4frame.h"
+-  "${LZ4_LIB_SOURCE_DIR}/xxhash.c")
++  "${LZ4_LIB_SOURCE_DIR}/lz4file.h"
++  "${LZ4_LIB_SOURCE_DIR}/lz4file.c")
+ set(LZ4_CLI_SOURCES
+   "${LZ4_PROG_SOURCE_DIR}/bench.c"
+   "${LZ4_PROG_SOURCE_DIR}/lz4cli.c"
+@@ -99,6 +100,9 @@ set(LZ4_CLI_SOURCES
+ # used.
+ option(LZ4_POSITION_INDEPENDENT_LIB "Use position independent code for static library (if applicable)" ON)
+ 
++find_package(PkgConfig REQUIRED)
++pkg_check_modules(XXHASH REQUIRED libxxhash)
++
+ # liblz4
+ set(LZ4_LIBRARIES_BUILT)
+ if(BUILD_SHARED_LIBS)
+@@ -115,6 +119,7 @@ if(BUILD_SHARED_LIBS)
+       LZ4_DLL_EXPORT=1)
+   endif()
+   list(APPEND LZ4_LIBRARIES_BUILT lz4_shared)
++  target_link_libraries(lz4_shared ${XXHASH_LIBRARIES})
+ endif()
+ if(BUILD_STATIC_LIBS)
+   set(STATIC_LIB_NAME lz4)
+@@ -129,6 +134,7 @@ if(BUILD_STATIC_LIBS)
+     OUTPUT_NAME ${STATIC_LIB_NAME}
+     POSITION_INDEPENDENT_CODE ${LZ4_POSITION_INDEPENDENT_LIB})
+   list(APPEND LZ4_LIBRARIES_BUILT lz4_static)
++  target_link_libraries(lz4_static ${XXHASH_STATIC_LIBRARIES})
+ endif()
+ 
+ if(BUILD_STATIC_LIBS)
+@@ -142,8 +148,9 @@ if (LZ4_BUILD_CLI)
+   set(LZ4_PROGRAMS_BUILT lz4cli)
+   add_executable(lz4cli ${LZ4_CLI_SOURCES})
+   set_target_properties(lz4cli PROPERTIES OUTPUT_NAME lz4)
++  target_link_libraries(lz4cli ${XXHASH_LIBRARIES})
+   if (BUILD_STATIC_LIBS)
+-    target_link_libraries(lz4cli ${LZ4_LINK_LIBRARY})
++    target_link_libraries(lz4cli ${LZ4_LINK_LIBRARY} ${XXHASH_STATIC_LIBRARIES})
+   endif()
+ endif()
+ 
+@@ -152,8 +159,9 @@ if (LZ4_BUILD_LEGACY_LZ4C)
+   list(APPEND LZ4_PROGRAMS_BUILT lz4c)
+   add_executable(lz4c ${LZ4_CLI_SOURCES})
+   set_target_properties(lz4c PROPERTIES COMPILE_DEFINITIONS "ENABLE_LZ4C_LEGACY_OPTIONS")
++  target_link_libraries(lz4c ${XXHASH_LIBRARIES})
+   if (BUILD_STATIC_LIBS)
+-    target_link_libraries(lz4c ${LZ4_LINK_LIBRARY})
++    target_link_libraries(lz4c ${LZ4_LINK_LIBRARY} ${XXHASH_STATIC_LIBRARIES})
+   endif()
+ endif()
+ 
diff --git a/debian/rules b/debian/rules
index e164ea7..2524ee8 100755
--- a/debian/rules
+++ b/debian/rules
@@ -27,16 +27,16 @@ endif
 %:
 	dh $@
 
+override_dh_auto_configure:
+	dh_auto_configure --buildsystem=cmake --sourcedirectory=build/cmake -- -DBUILD_STATIC_LIBS=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo
+
 override_dh_auto_build:
-	dh_auto_build -- CC=$(CC) V=1
+	dh_auto_build --buildsystem=cmake
 
 override_dh_auto_install:
-	dh_auto_install -- \
-		CC=$(CC) \
-		DESTDIR=$$(pwd)/debian/tmp \
-		LIBDIR=$(DESTDIR)/usr/lib/$(DEB_HOST_MULTIARCH)
+	dh_auto_install --buildsystem=cmake
 
 override_dh_auto_test:
 ifeq "$(disable_test)" "0"
-	make test
+	dh_auto_test --buildsystem=cmake
 endif
-- 
2.45.2

Reply via email to