File eigen.spec of Package eigen
#
# spec file for package eigen
#
# Copyright (c) 2025 SUSE LLC and contributors
#
# 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/
#
%global flavor @BUILD_FLAVOR@%{nil}
%if "%{flavor}" == "test"
%bcond_without test
%define psuffix -test
%else
%bcond_with test
%define psuffix %{nil}
%endif
%define pname eigen
%define major_ver 5.0
%define api_docdir %{_docdir}/%{name}/api
Name: %{pname}%{?psuffix}
Version: %{major_ver}.0
Release: 0
Summary: C++ template library for linear algebra
License: BSD-3-Clause AND MPL-2.0
URL: https://gitlab.com/libeigen/eigen
Source0: %{url}/-/archive/%{version}/%{pname}-%{version}.tar.bz2
Source1: https://libeigen.gitlab.io/eigen/docs-%{major_ver}/%{pname}-doc.tgz#/%{pname}-doc-%{major_ver}.tar.bz2
# PATCH-FEATURE-OPENSUSE eigen-no-world-in-pkgconfig-filename.patch badshah400@gmail.com -- Drop world version (3) from pkgconfig filename to allow parallel installation alongside eigen3, which also installs eigen3.pc
Patch0: eigen-no-world-in-pkgconfig-filename.patch
BuildRequires: adolc-devel
BuildRequires: cmake
BuildRequires: fdupes
BuildRequires: fftw3-devel
BuildRequires: gcc-c++
BuildRequires: gcc-fortran
BuildRequires: gmp-devel
BuildRequires: gsl-devel
BuildRequires: libboost_headers-devel
BuildRequires: metis-devel
BuildRequires: mpfr-devel
BuildRequires: pkg-config
BuildRequires: sparsehash-devel
BuildRequires: suitesparse-devel
BuildRequires: superlu-devel
BuildArch: noarch
%description
Eigen is a C++ template library for linear algebra: matrices, vectors,
numerical solvers, and related algorithms.
%package devel
Summary: C++ Template Library for Linear Algebra
%description devel
Eigen is a C++ template library for linear algebra: matrices, vectors,
numerical solvers, and related algorithms.
%package doc
Summary: Documentation for the Eigen C++ Template Library for Linear Algebra
%description doc
Documentation in HTML format for the Eigen C++ Template Library
for Linear Algebra
%prep
%autosetup -p1 -b1 -n %{pname}-%{version}
# Fix rpmlint warning "wrong-file-end-of-line-encoding"
sed -i 's/\r$//' COPYING.MINPACK
%build
%cmake \
-DCMAKE_SKIP_RPATH:BOOL=OFF \
-DCMAKE_SKIP_INSTALL_RPATH:BOOL=ON \
-DEIGEN_BUILD_BLAS:BOOL=OFF \
-DEIGEN_BUILD_LAPACK:BOOL=OFF \
-DBUILD_TESTING:BOOL=%{?with_test:ON}%{!?with_test:OFF} \
-DINCLUDE_INSTALL_DIR:PATH=include/eigen \
-DCMAKEPACKAGE_INSTALL_DIR=%{_datadir}/%{name}/cmake \
%{nil}
%cmake_build all %{?with_test:buildtests}
%install
%if %{without test}
%cmake_install
# Install bundled docs
mkdir -p %{buildroot}%{api_docdir}
cp -r ../eigen-doc/* %{buildroot}%{api_docdir}
%fdupes %{buildroot}%{api_docdir}
%endif
%if %{with test}
%check
# Run with a fixed seed to prevent random failures: https://gitlab.com/libeigen/eigen/-/issues/2088
export EIGEN_SEED=100
# Repeat each test once to reduce time spent, since we use a fixed seed anyway
export EIGEN_REPEAT=1
%ctest
%endif
%if %{without test}
%files devel
%license COPYING.*
%{_includedir}/eigen/
%{_datadir}/eigen/
%{_datadir}/pkgconfig/eigen.pc
%files doc
%dir %{_docdir}/%{pname}
%doc %{api_docdir}
%endif
%changelog