%global version_major 0
%global version_minor 5
%global version_patch 2

Name:       libpkgmanifest
Version:    0.5.2
Release:    1.20250226090725747363.main%{?dist}
Summary:    Library for working with RPM manifests
License:    GPL-2.0-or-later
URL:        https://github.com/rpm-software-management/libpkgmanifest
Source0:    libpkgmanifest-0.5.2.tar.gz

%bcond_with    clang
%bcond_without docs
%bcond_without python
%bcond_without tests

%if %{with clang}
%global toolchain clang
BuildRequires:  clang
%else
BuildRequires:  gcc-c++ >= 10.1
%endif

BuildRequires:  cmake >= 3.13
BuildRequires:  pkgconfig(yaml-cpp) >= 0.7.0

%if %{with tests}
BuildRequires:  pkgconfig(gmock)
BuildRequires:  pkgconfig(gtest)
%endif

%if %{with python}
BuildRequires:  python3-devel
BuildRequires:  swig >= 4.2.0
%endif

%description
libpkgmanifest is a library for parsing and creating RPM manifests.
It provides a native C++ API and Python bindings.

%files -n libpkgmanifest
%{_libdir}/libpkgmanifest.so

%package -n libpkgmanifest-devel
Summary:        Development files for libpkgmanifest
License:        LGPL-2.1-or-later
Requires:       libpkgmanifest%{?_isa} = %{version}-%{release}

%description -n libpkgmanifest-devel
Development files for libpkgmanifest.

%files -n libpkgmanifest-devel
%{_includedir}/libpkgmanifest/
%{_libdir}/libpkgmanifest.so
%{_libdir}/pkgconfig/libpkgmanifest.pc

%if %{with python}
%package -n python3-libpkgmanifest
%{?python_provide:%python_provide python3-libpkgmanifest}
Summary:        Python 3 bindings for the libpkgmanifest library
License:        LGPL-2.1-or-later
Requires:       libpkgmanifest%{?_isa} = %{version}-%{release}

%description -n python3-libpkgmanifest
Python 3 bindings for the libpkgmanifest library.

%files -n python3-libpkgmanifest
%{python3_sitearch}/libpkgmanifest
%{python3_sitearch}/libpkgmanifest-*.dist-info
%endif

%prep
%autosetup -p1 -n libpkgmanifest-0.5.2

%build
%cmake \
    -DWITH_DOCS=%{?with_docs:ON}%{!?with_docs:OFF} \
    -DWITH_PYTHON=%{?with_python:ON}%{!?with_python:OFF} \
    -DWITH_TESTS=%{?with_tests:ON}%{!?with_tests:OFF} \
    \
    -DVERSION_MAJOR=%{version_major} \
    -DVERSION_MINOR=%{version_minor} \
    -DVERSION_PATCH=%{version_patch}
%cmake_build

%install
%cmake_install

%changelog
%autochangelog