%bcond_without qt5
%bcond_without qt6

%undefine __cmake_in_source_build

Name:    libmygpo-qt
Summary: Qt Library that wraps the gpodder.net Web API
Version: 1.1.0
Release: 4%{?dist}

License: LGPLv2+
#Url:     http://wiki.gpodder.org/wiki/Libmygpo-qt
URL:     https://github.com/gpodder/libmygpo-qt/
Source0: https://github.com/gpodder/libmygpo-qt/archive/%{version}/%{name}-%{version}.tar.gz

Patch1:  0001-Add-missing-Qt5Network-Qt5Test-make-BUILD_WITH_QT4-m.patch
Patch2:  0002-Fix-build-with-Qt-5.11_beta3-dropping-qt5_use_module.patch
Patch3:  0003-Move-MYGPO_BUILD_TESTS-option.patch
Patch4:  0004-Update-the-minimum-required-cmake-version-to-3.0.patch
Patch5:  0005-Fix-parsing-of-timestamp-for-EpisodeAction.patch
Patch6:  0006-Fix-timestamp-sent-to-gpodder.net-to-correspond-to-U.patch
Patch7:  0007-Fix-removeList-of-DeviceUpdates.patch
Patch8:  0008-Use-c-c-library-defined-ULLONG_MAX-instead-of-manual.patch
Patch9:  0009-Update-signals-and-slots-to-use-Q_SIGNALS-and-Q_SLOT.patch
Patch10: 0010-Bump-minimum-CMake-version-to-avoid-a-warning-during.patch
# https://github.com/gpodder/libmygpo-qt/pull/23
Patch20: 0001-Minimal-changes-to-make-Qt6-compilation-possible.patch

BuildRequires: clang >= 19.0
BuildRequires: cmake
BuildRequires: doxygen


%description
libmygpo-qt is a Qt4 Library that wraps the gpodder.net Web API,
http://wiki.gpodder.org/wiki/Web_Services/API_2
 
%package devel
Summary: Development files for %{name}
Requires: %{name}%{?_isa} = %{version}-%{release}
%description devel
%{summary}.

%if %{with qt5}
%package -n libmygpo-qt5
Summary: Qt5 Library that wraps the gpodder.net Web API
BuildRequires: pkgconfig(Qt5Core)
BuildRequires: pkgconfig(Qt5Gui)
BuildRequires: pkgconfig(Qt5Network)

%description -n libmygpo-qt5
libmygpo-qt5 is a Qt5 Library that wraps the gpodder.net Web API,
http://wiki.gpodder.org/wiki/Web_Services/API_2

%package -n libmygpo-qt5-devel
Summary: Development files for libmygpo-qt5
Requires: libmygpo-qt5%{?_isa} = %{version}-%{release}
%description -n libmygpo-qt5-devel
%{summary}.
%endif

%if %{with qt5}
%package -n libmygpo-qt6
Summary: Qt6 Library that wraps the gpodder.net Web API
BuildRequires: pkgconfig(Qt6Core)
BuildRequires: pkgconfig(Qt6Gui)
BuildRequires: pkgconfig(Qt6Network)

%description -n libmygpo-qt6
libmygpo-qt6 is a Qt6 Library that wraps the gpodder.net Web API,
http://wiki.gpodder.org/wiki/Web_Services/API_2

%package -n libmygpo-qt6-devel
Summary: Development files for libmygpo-qt6
Requires: libmygpo-qt6%{?_isa} = %{version}-%{release}
%description -n libmygpo-qt6-devel
%{summary}.
%endif

%prep
%autosetup -p1


%build
export CC=clang
export CXX=clang++

%if %{with qt5}
%global _vpath_builddir %{_target_platform}-qt5

%{cmake} \
  -DBUILD_WITH_QT6:BOOL=OFF \
  -DINCLUDE_INSTALL_DIR:PATH=%{_qt5_headerdir}/mygpo-qt \
  -DLIB_INSTALL_DIR:PATH=%{_qt5_libdir}/mygpo-qt

%cmake_build
%endif

%if %{with qt6}
%global _vpath_builddir %{_target_platform}-qt6

%{cmake} \
  -DBUILD_WITH_QT6:BOOL=ON \
  -DINCLUDE_INSTALL_DIR:PATH=%{_qt6_headerdir}/mygpo-qt \
  -DLIB_INSTALL_DIR:PATH=%{_qt6_libdir}/mygpo-qt

%cmake_build
%endif

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

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

%check
%if %{with qt5}
export PKG_CONFIG_PATH=%{buildroot}%{_qt5_libdir}/pkgconfig
test "$(pkg-config --modversion libmygpo-qt5)" = "%{version}"
export CTEST_OUTPUT_ON_FAILURE=1
# test 2 currently fails on i686, poke upstream -- rex
make test -C %{_target_platform}-qt5 ||:
%endif

%if %{with qt6}
export PKG_CONFIG_PATH=%{buildroot}%{_qt6_libdir}/pkgconfig
test "$(pkg-config --modversion libmygpo-qt6)" = "%{version}"
export CTEST_OUTPUT_ON_FAILURE=1
# test 2 currently fails on i686, poke upstream -- rex
make test -C %{_target_platform}-qt6 ||:
%endif
 

%if %{with qt5}
%ldconfig_scriptlets -n libmygpo-qt5

%files -n libmygpo-qt5
%doc AUTHORS LICENSE README
%{_qt5_libdir}/libmygpo-qt5.so.1*

%files -n libmygpo-qt5-devel
%{_qt5_headerdir}/mygpo-qt/
%{_qt5_libdir}/libmygpo-qt5.so
%{_qt5_libdir}/pkgconfig/libmygpo-qt5.pc
%{_qt5_libdir}/cmake/mygpo-qt5/
%endif

%if %{with qt6}
%ldconfig_scriptlets -n libmygpo-qt6

%files -n libmygpo-qt6
%doc AUTHORS LICENSE README
%{_qt6_libdir}/libmygpo-qt6.so.1*

%files -n libmygpo-qt6-devel
%{_qt6_headerdir}/mygpo-qt/
%{_qt6_libdir}/libmygpo-qt6.so
%{_qt6_libdir}/pkgconfig/libmygpo-qt6.pc
%{_qt6_libdir}/cmake/mygpo-qt6/
%endif
 
%changelog
* Mon Jan 13 2025 Raven <raven@sysadmins.ws> - 1.1.0-4
- drop qt4 support
- build with qt6

* Thu Jul 25 2019 Fedora Release Engineering <releng@fedoraproject.org> - 1.1.0-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild

* Fri Feb 01 2019 Fedora Release Engineering <releng@fedoraproject.org> - 1.1.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild

* Tue Oct 23 2018 Rex Dieter <rdieter@fedoraproject.org> - 1.1.0-1
- 1.1.0
- use %%make_build %%ldconfig_scriptlets
- make qt5 unconditional
- conditionalize qt4 support (which is deprecated upstream)

* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.8-10
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild

* Wed Feb 07 2018 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.8-9
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild

* Thu Aug 03 2017 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.8-8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild

* Wed Jul 26 2017 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.8-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild

* Fri Feb 10 2017 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.8-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild

* Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 1.0.8-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild

* Wed Jun 17 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.0.8-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild

* Sat May 02 2015 Kalev Lember <kalevlember@gmail.com> - 1.0.8-3
- Rebuilt for GCC 5 C++11 ABI change

* Thu Oct 09 2014 Rex Dieter <rdieter@fedoraproject.org> 1.0.8-2
- qt5-devel: fix typo in base pkg dependency

* Wed Oct 01 2014 Rex Dieter <rdieter@fedoraproject.org> 1.0.8-1
- 1.0.8
- include path for cmake and chkconfig are wrong for libmygpo-qt (#1148246)
- use github-hosted sources
- Qt5 support: libmygpo-qt5,libmy-qt5-devel subpkgs

* Sun Aug 17 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.0.7-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild

* Sat Jun 07 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.0.7-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild

* Sat Aug 03 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.0.7-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild

* Sat Apr 13 2013 Rex Dieter <rdieter@fedoraproject.org> 1.0.7-1
- 1.0.7

* Thu Feb 14 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.0.6-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild

* Tue Nov 27 2012 Rex Dieter <rdieter@fedoraproject.org> 1.0.6-3
- rebuild (qjson)

* Fri Nov 23 2012 Rex Dieter <rdieter@fedoraproject.org> 1.0.6-2
- rebuild (qjson)

* Sat Oct 13 2012 Rex Dieter <rdieter@fedoraproject.org> 1.0.6-1
- 1.0.6

* Thu Jul 19 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.0.5-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild

* Tue Feb 28 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.0.5-3
- Rebuilt for c++ ABI breakage

* Fri Jan 13 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.0.5-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild

* Wed Nov 09 2011 Rex Dieter <rdieter@fedoraproject.org> 1.0.5-1
- 1.0.5

* Wed Sep 14 2011 Rex Dieter <rdieter@fedoraproject.org> 1.0.4-1
- 1.0.4

* Mon May 23 2011 Rex Dieter <rdieter@fedoraproject.org> 1.0.3-1
- 1.0.3

* Fri May 20 2011 Rex Dieter <rdieter@fedoraproject.org> 1.0.2-2
- drop kde deps/macros, this is a qt-only library

* Tue May 10 2011 Rex Dieter <rdieter@fedoraproject.org> 1.0.2-1
- 1.0.2 first try


