Blob Blame History Raw
%bcond_with toolchain_clang

%if %{with toolchain_clang}
%global toolchain clang

%bcond_without build_tests
# tests not discoverable by ctest yet
%bcond_with check

%global forgeurl
%global tag 2024.02.19.00
%global date %(echo %{tag} | sed -e 's|.00$||' | sed -e 's|\\.||g')
# disable forge macro snapinfo generation
%global distprefix %{nil}

# see cachelib/allocator/CacheVersion.h's kCachelibVersion
%global major_ver 17

Name:           cachelib
Version:        %{major_ver}^%{date}
Release:        %autorelease
Summary:        Pluggable caching engine for scale high performance cache services

License:        Apache-2.0
URL:            %forgeurl
Source0:        %{url}/archive/v%{tag}/%{name}-%{tag}.tar.gz
# needed on EL8; its gtest does not come with cmake files
Patch100:       %{name}-find-gtest.patch
# Workaround for gcc issue (still needed on epel9 x86_64)
Patch200:         %{name}-workaround-gcc-epel9-x86_64-bz2108665.patch

ExclusiveArch:  x86_64 aarch64 ppc64le

BuildRequires:  cmake
%if %{with toolchain_clang}
BuildRequires:  clang
BuildRequires:  gcc-c++
BuildRequires:  fbthrift-devel = %{tag}
BuildRequires:  fizz-devel = %{tag}
BuildRequires:  folly-devel = %{tag}
BuildRequires:  mvfst-devel = %{tag}
%if %{with build_tests}
BuildRequires:  gmock-devel
# this is actually needed, because of
# cachelib/navy/admission_policy/DynamicRandomAP.h
BuildRequires:  gtest-devel
BuildRequires:  libdwarf-devel
BuildRequires:  libzstd-devel
BuildRequires:  numactl-devel
BuildRequires:  wangle-devel
BuildRequires:  zlib-devel
BuildRequires:  tsl-sparse-map-devel
# BuildRequires:  libatomic

%global _description %{expand:
CacheLib is a C++ library providing in-process high performance caching
mechanism. CacheLib provides a thread safe API to build high throughput, low
overhead caching services, with built-in ability to leverage DRAM and SSD
caching transparently.}

%description %{_description}

%package devel
Summary:        %{summary}
Requires:       %{name}%{?_isa} = %{version}-%{release}
Requires:       cmake

%description devel %{_description}

The %{name}-devel package contains libraries and header files for developing
applications that use %{name}.

%autosetup -n CacheLib-%{tag} -N
%autopatch -p1 -M 99
%if 0%{?el8}
%autopatch -p1 -m 100 -M 199
%ifarch x86_64
%if 0%{?el9}
%autopatch -p1 -m 200 -M 209

pushd %{name}
%cmake \
%if %{with build_tests}
  -DCMAKE_INSTALL_DIR:PATH=%{_libdir}/cmake/%{name} \
  -DCONFIGS_INSTALL_DIR:STRING=%{_datadir}/%{name}/test_configs \
  -DINCLUDE_INSTALL_DIR:PATH=%{_includedir}/%{name} \

pushd %{name}
%if %{with build_tests}
# TODO: prevent tests being installed
rm -rf %{buildroot}%{_prefix}/tests

%if %{with check}
pushd %{name}

%license LICENSE
%doc examples

%files devel