File fmt.spec of Package fmt-7.1.3

%undefine __cmake_in_source_build
%bcond_with doc
Name:                fmt
Version:             7.1.3
Release:             1
Summary:             Small, safe and fast formatting library for C++
License:             BSD
URL:                 https://github.com/fmtlib/%{name}
Source0:             %{url}/archive/%{version}.tar.gz
Patch1:              doc-build-removed-all-pip-internet-stuff.patch
Patch3:              doc-build-do-not-create-virtual-environment.patch
Patch4:              doc-_templates-layout-stripped-Google-Analytics.patch
Patch5:              doc-_templates-layout-stripped-download-links.patch
Patch6:              doc-index-removed-GitHub-iframe.patch
Patch7:              doc-build-use-sphinx-build-3.patch
BuildRequires:       gcc gcc-c++ ninja-build cmake
%if %{with doc}
BuildRequires:       doxygen nodejs-less python3-sphinx python3-breathe
%else
Provides:            %{name}-doc = %{?epoch:%{epoch}:}%{version}-%{release}
Obsoletes:           %{name}-doc < %{?epoch:%{epoch}:}%{version}-%{release}
%endif
Provides:            cppformat = %{?epoch:%{epoch}:}%{version}-%{release}
Obsoletes:           cppformat < %{?epoch:%{epoch}:}%{version}-%{release}
%description
C++ Format is an open-source formatting library for C++. It can be used as a
safe alternative to printf or as a fast alternative to IOStreams.

%package        devel
Summary:             Development files for %{name}
Requires:            %{name}%{?_isa} = %{?epoch:%{epoch}:}%{version}-%{release}
Provides:            cppformat-devel = %{?epoch:%{epoch}:}%{version}-%{release}
Obsoletes:           cppformat-devel < %{?epoch:%{epoch}:}%{version}-%{release}
%description    devel
This package contains the header file for using %{name}.
%if %{with doc}

%package        doc
Summary:             Documentation files for %{name}
License:             Python
BuildArch:           noarch
Provides:            cppformat-doc = %{?epoch:%{epoch}:}%{version}-%{release}
Obsoletes:           cppformat-doc < %{?epoch:%{epoch}:}%{version}-%{release}
%description    doc
This package contains documentation for developer documentation for %{name}.
%endif

%prep
%autosetup -p1
%if %{with doc}
sed -i "s/'--clean-css',//" doc/build.py
%endif

%build
%cmake                                        \
    -G Ninja                                  \
    -DCMAKE_BUILD_TYPE=RelWithDebInfo         \
    -DCMAKE_POSITION_INDEPENDENT_CODE=ON      \
    -DFMT_CMAKE_DIR=%{_libdir}/cmake/%{name}  \
    -DFMT_LIB_DIR=%{_libdir}
cmake --build  ./ %{?_smp_flags} --verbose --target all
%if %{with doc}
    --target doc \
%endif
    
%if %{with doc}
rm -rf %{_vpath_builddir}/doc/html/{.buildinfo,.doctrees,objects.inv}
%endif

%install
install -d -m 0755 %{buildroot}/%{_includedir}/%{name}
install -d -m 0755 %{buildroot}/%{_libdir}
install -d -m 0755 %{buildroot}/%{_libdir}/cmake/%{name}
install -d -m 0755 %{buildroot}/%{_libdir}/pkgconfig
cp  -arf  include/fmt/*  %{buildroot}/%{_includedir}/%{name}
cp  -arf lib%{name}.so %{buildroot}/%{_libdir}
cp  -arf lib%{name}.so.7.1.3 %{buildroot}/%{_libdir}
cp  -arf lib%{name}.so.7 %{buildroot}/%{_libdir}
cp  -arf fmt.pc   %{buildroot}/%{_libdir}/pkgconfig
cp  -arf  *.cmake  %{buildroot}/%{_libdir}/cmake/%{name}

%check

%files
%license LICENSE.rst
%doc ChangeLog.rst README.rst
%{_libdir}/lib%{name}.so.7*

%files devel
%{_includedir}/%{name}
%{_libdir}/lib%{name}.so
%{_libdir}/cmake/%{name}
%{_libdir}/pkgconfig/%{name}.pc
%if %{with doc}

%files doc
%doc %{_datadir}/doc/%{name}
%license doc/python-license.txt
%endif

%changelog
* Thu Nov 25 2021 liyanan <liyanan32@huawei.com> - 7.1.3-1
- package init