File kleidiai.spec of Package kleidiai

#
# spec file for package ComputeLibrary
#
# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#

# https://gitlab.arm.com/kleidi/kleidiai/-/issues/6
%define _lto_cflags %{nil}

%bcond_without tests
%if 0%{?sle_version} >= 150000 && 0%{?sle_version} < 160000
# Benchmark is too old on Leap/SLE 15.x
%bcond_with benchmark
%else
%bcond_without benchmark
%endif

%define version_lib 0
Name:           kleidiai
Version:        1.8.0
Release:        0
Summary:        KleidiAI is an open-source library that provides optimized performance-critical
License:        Apache-2.0
URL:            https://www.arm.com/products/development-tools/embedded-and-software/kleidi
Source:         https://gitlab.arm.com/kleidi/kleidiai/-/archive/v%{version}/kleidiai-v%{version}.tar.gz
#
Patch1:         kleidiai-fix-soversion.patch
# 
Patch2:         kleidiai-install_test.patch
#
Patch3:         kleidiai-install_benchmark.patch
BuildRequires:  cmake >= 3.18
%if 0%{?sle_version} >= 150000 && 0%{?sle_version} < 160000
BuildRequires:  gcc14
BuildRequires:  gcc14-c++
%else
BuildRequires:  gcc-c++ >= 13
%endif
%if %{with tests}
BuildRequires:  gmock
BuildRequires:  gtest
%endif
%if %{with benchmark}
BuildRequires:  benchmark-devel
%endif
ExclusiveArch:  aarch64

%description
KleidiAI is an open-source library that provides optimized performance-critical
routines, also known as micro-kernels, for artificial intelligence (AI) 
workloads tailored for ArmĀ® CPUs.

%package -n libkleidiai%{version_lib}
Summary:        libkleidiai from KleidiAI
Group:          Development/Libraries/C and C++

%description -n libkleidiai%{version_lib}
This package contains the libkleidiai library from KleidiAI

%package devel
Summary:        Development headers and libraries for KleidiAI
Group:          Development/Libraries/C and C++
Requires:       libkleidiai = %{version}

%description devel
This package contains the development libraries and headers for KleidiAI

%post -n  libkleidiai%{version_lib} -p /sbin/ldconfig
%postun -n  libkleidiai%{version_lib} -p /sbin/ldconfig

%prep
%autosetup -p1 -n kleidiai-v%{version}

%build
%cmake \
%if 0%{?sle_version} >= 150000 && 0%{?sle_version} < 160000
  -DCMAKE_C_COMPILER="gcc-14" \
  -DCMAKE_CXX_COMPILER="g++-14" \
%endif
%if %{with tests}
  -DKLEIDIAI_BUILD_TESTS=ON \
%else
  -DKLEIDIAI_BUILD_TESTS=OFF \
%endif
%if %{with benchmark}
  -DKLEIDIAI_BUILD_BENCHMARK=ON \
%endif

%cmake_build

%install
%cmake_install

%check
%if %{with tests}
# Currently, all kleidiai_test test are run, whatever the host supports,
# which leads to illegal instructions
#./build/kleidiai_test
%endif
%if %{with benchmark}
# Benchmark - Only run dotprod since i8mm is unsupported on OBS hardare
./build/kleidiai_benchmark --benchmark_filter=dotprod -m 13 -n 17 -k 18
%endif

%files
%if %{with tests}
%{_bindir}/kleidiai_test
%endif
%if %{with benchmark}
%{_bindir}/kleidiai_benchmark
%endif

%files -n libkleidiai%{version_lib}
%{_libdir}/libkleidiai.so.*

%files devel
%{_libdir}/libkleidiai.so
%dir %{_includedir}/kai
%{_includedir}/kai/*
%dir %{_libdir}/cmake/KleidiAI
%{_libdir}/cmake/KleidiAI/*

%changelog
openSUSE Build Service is sponsored by