File fmt.spec of Package fmt

#
# spec file for package fmt
#
# Copyright (c) 2021 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/
#


%define sover   8
Name:           fmt
Version:        8.1.1
Release:        0
Summary:        A formatting library for C++
License:        MIT
URL:            http://fmtlib.net/
Source0:        %{name}-%{version}.tar.xz
Source1:        baselibs.conf
Patch0:         %{name}_cxx_standard.patch
BuildRequires:  cmake
%if 0%{?suse_version} <= 1500 
BuildRequires: gcc10
BuildRequires: gcc10-c++
%else
BuildRequires: gcc-c++
%endif
BuildRequires:  pkgconfig

%description
Fmt is a formatting library for C++. It can be used as an
alternative to (s)printf and IOStreams.

%package -n libfmt%{sover}
Summary:        A formatting library for C++

%description -n libfmt%{sover}
Shared library for fmt, a formatting library for C++.

%package devel
Summary:        Development files for fmt, a formatting library
Requires:       libfmt%{sover} = %{version}

%description devel
Development files for fmt, a formatting library for C++.

%prep
%autosetup -p1

%build
export CFLAGS="%optflags -flto=auto"
export CXXFLAGS="%optflags -flto=auto"
export LDFLAGS="$(CFLAGS) ${LDFLAGS}"
test -x "$(type -p gcc)"   && export CC="$_"
test -x "$(type -p g++)"   && export CXX="$_"
test -x "$(type -p gcc-7)" && export CC="$_"
test -x "$(type -p g++-7)" && export CXX="$_"
test -x "$(type -p gcc-8)" && export CC="$_"
test -x "$(type -p g++-8)" && export CXX="$_"
test -x "$(type -p gcc-9)" && export CC="$_"
test -x "$(type -p g++-9)" && export CXX="$_"
test -x "$(type -p gcc-10)" && export CC="$_"
test -x "$(type -p g++-10)" && export CXX="$_"
test -x "$(type -p gcc-11)" && export CC="$_"
test -x "$(type -p g++-11)" && export CXX="$_"
%cmake -DCMAKE_INSTALL_INCLUDEDIR:PATH=%{_includedir}
%make_jobs

%install
%cmake_install

%check
# path needs to be exported otherwise unit tests will fail
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:%{buildroot}%{_libdir}
%ctest

%post -n libfmt%{sover} -p /sbin/ldconfig
%postun -n libfmt%{sover} -p /sbin/ldconfig

%files -n libfmt%{sover}
%license LICENSE.rst
%{_libdir}/libfmt.so.%{sover}*

%files devel
%doc ChangeLog.rst README.rst
%{_includedir}/%{name}
%{_libdir}/cmake/%{name}
%{_libdir}/libfmt.so
%{_libdir}/pkgconfig/%{name}.pc

%changelog
openSUSE Build Service is sponsored by