## START: Set by rpmautospec
## (rpmautospec version 0.6.3)
## RPMAUTOSPEC: autorelease, autochangelog
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
    release_number = 4;
    base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}"));
    print(release_number + base_release_number - 1);
}%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{!?-n:%{?dist}}
## END: Set by rpmautospec

%bcond_without qt5
%if 0%{?rhel} == 9
%bcond_with qt6
%else
%bcond_without qt6
%endif
# currently broken
%bcond_with docs
%bcond_without test

%global forgeurl https://github.com/KDAB/KDSingleApplication/
# bumping this requires rebuild of dependent pkgs!
%global soversion 1.1

%global cmake_args -DKDSingleApplication_TESTS=true
%if %{with docs}
%global cmake_args %cmake_args -DKDSingleApplication_DOCS=true
%endif

Name:           kdsingleapplication
Version:        1.1.0
Release:        %autorelease
Summary:        KDAB's helper class for single-instance policy applications
%forgemeta
URL:            %{forgeurl}
Source:         %{forgesource}
License:        MIT

BuildRequires:  cmake
BuildRequires:  gcc-c++
%if %{with qt5}
BuildRequires:  kf5-rpm-macros
BuildRequires:  cmake(Qt5Core)
BuildRequires:  cmake(Qt5Network)
BuildRequires:  cmake(Qt5Widgets)
%endif
%if %{with qt6}
BuildRequires:  kf6-rpm-macros
BuildRequires:  cmake(Qt6Core)
BuildRequires:  cmake(Qt6Network)
BuildRequires:  cmake(Qt6Widgets)
%endif
%if %{with docs}
BuildRequires:  doxygen
%endif

%global _description %{expand:
KDSingleApplication is a helper class for single-instance policy applications
written by KDAB.}

%description %_description

%prep
%forgeautosetup -p1

%build
%if %{with qt5}
%global _vpath_builddir build-qt5
%cmake_kf5 %cmake_args
%cmake_build
%endif

%if %{with qt6}
%global _vpath_builddir build-qt6
%cmake_kf6 %cmake_args -DKDSingleApplication_QT6=true
%cmake_build
%endif

%install
%if %{with qt5}
%global _vpath_builddir build-qt5
%cmake_install
%endif

%if %{with qt6}
%global _vpath_builddir build-qt6
%cmake_install
%endif

%if %{with test}
%check
%if %{with qt5}
%global _vpath_builddir build-qt5
%ctest
%endif

%if %{with qt6}
%global _vpath_builddir build-qt6
%ctest
%endif
%endif

%if %{with qt5}
%package qt5
Summary:      KDAB's helper class for single-instance policy applications (Qt5)

%description qt5 %_description

%files qt5
%license LICENSES/MIT.txt
%{_libdir}/libkdsingleapplication.so.%{soversion}
%{_libdir}/libkdsingleapplication.so.%{version}
%{_docdir}/KDSingleApplication

%package qt5-devel
Summary:      Development files for %{name}-qt5
Requires:     %{name}-qt5%{?_isa} = %{version}-%{release}
Requires:     cmake(Qt5Core)
Requires:     cmake(Qt5Network)
Requires:     cmake(Qt5Widgets)

%description qt5-devel
The %{name}-qt5-devel package contains libraries, header files and
documentation for developing applications that use %{name}-qt5.

%files qt5-devel
%license LICENSES/MIT.txt
%{_libdir}/libkdsingleapplication.so
%{_libdir}/cmake/KDSingleApplication/
%{_qt5_archdatadir}/mkspecs/modules/*
%{_includedir}/kdsingleapplication/
%endif

%if %{with qt6}
%package qt6
Summary:      KDAB's helper class for single-instance policy applications (Qt6)

%description qt6 %_description

%files qt6
%license LICENSES/MIT.txt
%{_libdir}/libkdsingleapplication-qt6.so.%{soversion}
%{_libdir}/libkdsingleapplication-qt6.so.%{version}
%{_docdir}/KDSingleApplication-qt6

%package qt6-devel
Summary:      Development files for %{name}-qt6
Requires:     %{name}-qt6%{?_isa} = %{version}-%{release}
Requires:     cmake(Qt6Core)
Requires:     cmake(Qt6Network)
Requires:     cmake(Qt6Widgets)

%description qt6-devel
The %{name}-qt6-devel package contains libraries, header files and
documentation for developing applications that use %{name}-qt6.

%files qt6-devel
%license LICENSES/MIT.txt
%{_libdir}/libkdsingleapplication-qt6.so
%{_libdir}/cmake/KDSingleApplication-qt6/
%{_qt6_mkspecsdir}/modules/*
%{_includedir}/kdsingleapplication-qt6/
%endif

%changelog
## START: Generated by rpmautospec
* Fri May 10 2024 Yaakov Selkowitz <yselkowi@redhat.com> - 1.1.0-4
- Build with KDE macros

* Wed Jan 24 2024 Fedora Release Engineering <releng@fedoraproject.org> - 1.1.0-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

* Sun Jan 21 2024 Fedora Release Engineering <releng@fedoraproject.org> - 1.1.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

* Sat Dec 23 2023 Ondrej Mosnáček <omosnacek@gmail.com> - 1.1.0-1
- Update to version 1.1.0 (fedora#2255689)

* Sat Dec 23 2023 Ondrej Mosnáček <omosnacek@gmail.com> - 1.0.0-3
- Fix macro recursion for cmake_args

* Mon Nov 27 2023 Ondrej Mosnáček <omosnacek@gmail.com> - 1.0.0-2
- Fix .so file listing

* Mon Nov 27 2023 Ondrej Mosnáček <omosnacek@gmail.com> - 1.0.0-1
- Initial import (fedora#2250313)
## END: Generated by rpmautospec
