From 26145b97ee68a91cd67e43f7816e89fe8e3c1250 Mon Sep 17 00:00:00 2001 From: Funda Wang Date: Tue, 4 Nov 2025 22:13:01 +0800 Subject: [PATCH] build with cmake --- zstd.spec | 44 +++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/zstd.spec b/zstd.spec index 4e9387c..048f45a 100644 --- a/zstd.spec +++ b/zstd.spec @@ -2,7 +2,7 @@ Name: zstd Version: 1.5.7 -Release: 3 +Release: 4 Summary: A fast lossless compression algorithm License: BSD-3-Clause AND GPL-2.0-only URL: https://github.com/facebook/zstd @@ -11,12 +11,10 @@ Source0: https://github.com/facebook/zstd/archive/v%{version}.tar.gz#/%{ Patch9000: update-rm-command-description.patch BuildRequires: gcc gcc-c++ +BuildRequires: cmake >= 3.10 BuildRequires: pkgconfig(liblz4) BuildRequires: pkgconfig(liblzma) BuildRequires: pkgconfig(zlib) -%if %{with pzstd} -BuildRequires: pkgconfig(gtest) -%endif Provides: libzstd = %{version}-%{release} Obsoletes: libzstd < %{version}-%{release} @@ -43,26 +41,29 @@ This package contains the header files for zstd library. %autosetup -p1 %build -export CFLAGS="$RPM_OPT_FLAGS" -export LDFLAGS="$RPM_LD_FLAGS" -for dir in lib programs; do - %make_build -C "$dir" -done -%if %{with pzstd} -%make_build -C contrib/pzstd CXXFLAGS="$RPM_OPT_FLAGS -std=c++11" -%endif +%global _vpath_srcdir build/cmake +%global _vpath_builddir build/shared +%cmake %{?with_pzstd:-DZSTD_BUILD_CONTRIB=ON} -DZSTD_BUILD_STATIC=NO -DZSTD_PROGRAMS_LINK_SHARED=YES +%cmake_build + +%global _vpath_builddir build/static +%cmake %{?with_pzstd:-DZSTD_BUILD_CONTRIB=ON} -DZSTD_BUILD_SHARED=NO -DBUILD_TESTING=YES +%cmake_build %check -%make_build -C tests test-zstd -%if %{with pzstd} -%make_build -C contrib/pzstd test CXXFLAGS="$RPM_OPT_FLAGS -std=c++11" -%endif +%global _vpath_builddir build/static +%ctest --verbose %install -%make_install PREFIX=%{_prefix} LIBDIR=%{_libdir} +%global _vpath_builddir build/static +%cmake_install + +# Install shared second so that cmake config files reference the shared library +%global _vpath_builddir build/shared +%cmake_install + %if %{with pzstd} -install -D -m755 contrib/pzstd/pzstd %{buildroot}%{_bindir}/pzstd -install -D -m644 programs/zstd.1 %{buildroot}%{_mandir}/man1/pzstd.1 +install -D -m644 programs/%{name}.1 %{buildroot}%{_mandir}/man1/p%{name}.1 %endif %files @@ -76,11 +77,16 @@ install -D -m644 programs/zstd.1 %{buildroot}%{_mandir}/man1/pzstd.1 %{_libdir}/pkgconfig/libzstd.pc %{_libdir}/libzstd.so %{_libdir}/libzstd.a +%{_libdir}/cmake/zstd %files help %{_mandir}/man1/*.1* +%doc %{_datadir}/doc/zstd/zstd_manual.html %changelog +* Tue Nov 04 2025 Funda Wang - 1.5.7-4 +- build with cmake + * Tue May 27 2025 shixuantong - 1.5.7-3 - fix changelog -- Gitee