Allow building subpackages for individual Qt versions conditionally

Provide conditionals for building for only a subset of Qt versions. This
will be useful for implementing EPEL8 support.

Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
epel9
Ondrej Mosnacek 3 years ago
parent f00a583b9e
commit a870e56457

@ -1,5 +1,9 @@
%undefine __cmake_in_source_build %undefine __cmake_in_source_build
%bcond_without qt4
%bcond_without qt5
%bcond_without qt6
%bcond_without test %bcond_without test
Name: quazip Name: quazip
@ -13,10 +17,17 @@ Source0: %{url}/archive/v%{version}/%{name}-v%{version}.tar.gz
Source1: FindQuaZip.cmake Source1: FindQuaZip.cmake
BuildRequires: cmake BuildRequires: cmake
BuildRequires: gcc-c++ BuildRequires: gcc-c++
BuildRequires: zlib-devel
%if %{with qt4}
BuildRequires: qt4-devel BuildRequires: qt4-devel
%endif
%if %{with qt5}
BuildRequires: qt5-qtbase-devel BuildRequires: qt5-qtbase-devel
%endif
%if %{with qt6}
BuildRequires: qt6-qtbase-devel BuildRequires: qt6-qtbase-devel
BuildRequires: qt6-qt5compat-devel BuildRequires: qt6-qt5compat-devel
%endif
BuildRequires: doxygen graphviz BuildRequires: doxygen graphviz
@ -31,6 +42,8 @@ whatever you would like to use on your zipped files.
QuaZIP provides complete abstraction of the ZIP/UNZIP API, for both reading QuaZIP provides complete abstraction of the ZIP/UNZIP API, for both reading
from and writing to ZIP archives. from and writing to ZIP archives.
%if %{with qt4}
%package devel %package devel
Summary: Development files for %{name} Summary: Development files for %{name}
Requires: %{name}%{?_isa} = %{version}-%{release} Requires: %{name}%{?_isa} = %{version}-%{release}
@ -40,7 +53,9 @@ Requires: zlib-devel%{?_isa}
%description devel %description devel
The %{name}-devel package contains libraries, header files and documentation The %{name}-devel package contains libraries, header files and documentation
for developing applications that use %{name}. for developing applications that use %{name}.
%endif
%if %{with qt5}
%package qt5 %package qt5
Summary: Qt5 wrapper for the minizip library Summary: Qt5 wrapper for the minizip library
%description qt5 %description qt5
@ -63,7 +78,9 @@ Requires: zlib-devel%{?_isa}
%description qt5-devel %description qt5-devel
The %{name}-qt5-devel package contains libraries, header files and documentation The %{name}-qt5-devel package contains libraries, header files and documentation
for developing applications that use %{name}-qt5. for developing applications that use %{name}-qt5.
%endif
%if %{with qt6}
%package qt6 %package qt6
Summary: Qt6 wrapper for the minizip library Summary: Qt6 wrapper for the minizip library
%description qt6 %description qt6
@ -87,23 +104,30 @@ Requires: zlib-devel%{?_isa}
%description qt6-devel %description qt6-devel
The %{name}-qt6-devel package contains libraries, header files and documentation The %{name}-qt6-devel package contains libraries, header files and documentation
for developing applications that use %{name}-qt6. for developing applications that use %{name}-qt6.
%endif
%prep %prep
%autosetup -p1 %autosetup -p1
%build %build
%if %{with qt4}
%global _vpath_builddir build-qt4 %global _vpath_builddir build-qt4
%cmake -DQUAZIP_QT_MAJOR_VERSION=4 %cmake -DQUAZIP_QT_MAJOR_VERSION=4
%cmake_build %cmake_build
%endif
%if %{with qt5}
%global _vpath_builddir build-qt5 %global _vpath_builddir build-qt5
%cmake -DQUAZIP_QT_MAJOR_VERSION=5 %cmake -DQUAZIP_QT_MAJOR_VERSION=5
%cmake_build %cmake_build
%endif
%if %{with qt6}
%global _vpath_builddir build-qt6 %global _vpath_builddir build-qt6
%cmake -DQUAZIP_QT_MAJOR_VERSION=6 %cmake -DQUAZIP_QT_MAJOR_VERSION=6
%cmake_build %cmake_build
%endif
doxygen Doxyfile doxygen Doxyfile
for file in doc/html/*; do for file in doc/html/*; do
@ -111,12 +135,20 @@ for file in doc/html/*; do
done done
%install %install
%if %{with qt4}
%global _vpath_builddir build-qt4 %global _vpath_builddir build-qt4
%cmake_install %cmake_install
%endif
%if %{with qt5}
%global _vpath_builddir build-qt5 %global _vpath_builddir build-qt5
%cmake_install %cmake_install
%endif
%if %{with qt6}
%global _vpath_builddir build-qt6 %global _vpath_builddir build-qt6
%cmake_install %cmake_install
%endif
# Create compat symlinks/files so that packages that use the old (pre-1.0) # Create compat symlinks/files so that packages that use the old (pre-1.0)
# library location, include paths, or CMake module still build against the # library location, include paths, or CMake module still build against the
@ -125,8 +157,8 @@ done
# #
# These symlinks should probably be removed once all dependent packages are # These symlinks should probably be removed once all dependent packages are
# switched to use the new pkgconfig or CMake modules. # switched to use the new pkgconfig or CMake modules.
%if %{with qt4}
ln -s libquazip1-qt4.so %{buildroot}%{_libdir}/libquazip.so ln -s libquazip1-qt4.so %{buildroot}%{_libdir}/libquazip.so
ln -s libquazip1-qt5.so %{buildroot}%{_libdir}/libquazip5.so
install -d %{buildroot}%{_includedir}/quazip install -d %{buildroot}%{_includedir}/quazip
pushd %{buildroot}%{_includedir}/QuaZip-Qt4-1.1/quazip pushd %{buildroot}%{_includedir}/QuaZip-Qt4-1.1/quazip
@ -135,6 +167,13 @@ for f in *; do
done done
popd popd
install -d %{buildroot}%{_datadir}/cmake/Modules
install -pm 0644 %{SOURCE1} %{buildroot}%{_datadir}/cmake/Modules/FindQuaZip.cmake
%endif
%if %{with qt5}
ln -s libquazip1-qt5.so %{buildroot}%{_libdir}/libquazip5.so
install -d %{buildroot}%{_includedir}/quazip5 install -d %{buildroot}%{_includedir}/quazip5
pushd %{buildroot}%{_includedir}/QuaZip-Qt5-1.1/quazip pushd %{buildroot}%{_includedir}/QuaZip-Qt5-1.1/quazip
for f in *; do for f in *; do
@ -143,8 +182,9 @@ done
popd popd
install -d %{buildroot}%{_datadir}/cmake/Modules install -d %{buildroot}%{_datadir}/cmake/Modules
install -pm 0644 %{SOURCE1} %{buildroot}%{_datadir}/cmake/Modules/FindQuaZip.cmake
install -pm 0644 %{SOURCE1} %{buildroot}%{_datadir}/cmake/Modules/FindQuaZip5.cmake install -pm 0644 %{SOURCE1} %{buildroot}%{_datadir}/cmake/Modules/FindQuaZip5.cmake
%endif
%if %{with test} %if %{with test}
%check %check
@ -158,16 +198,25 @@ export LC_ALL=C.UTF-8
# test failures. # test failures.
export QT_ENABLE_REGEXP_JIT=0 export QT_ENABLE_REGEXP_JIT=0
%if %{with qt4}
%global _vpath_builddir build-qt4 %global _vpath_builddir build-qt4
%cmake_build -t check %cmake_build -t check
%endif
%if %{with qt5}
%global _vpath_builddir build-qt5 %global _vpath_builddir build-qt5
%cmake_build -t check %cmake_build -t check
%endif
%if %{with qt6}
%global _vpath_builddir build-qt6 %global _vpath_builddir build-qt6
%cmake_build -t check %cmake_build -t check
%endif %endif
%endif
%ldconfig_scriptlets %ldconfig_scriptlets
%if %{with qt4}
%files %files
%doc NEWS.txt README.md %doc NEWS.txt README.md
%license COPYING %license COPYING
@ -183,7 +232,9 @@ export QT_ENABLE_REGEXP_JIT=0
%{_includedir}/quazip/ %{_includedir}/quazip/
%{_libdir}/libquazip.so %{_libdir}/libquazip.so
%{_datadir}/cmake/Modules/FindQuaZip.cmake %{_datadir}/cmake/Modules/FindQuaZip.cmake
%endif
%if %{with qt5}
%files qt5 %files qt5
%doc NEWS.txt README.md %doc NEWS.txt README.md
%license COPYING %license COPYING
@ -199,7 +250,9 @@ export QT_ENABLE_REGEXP_JIT=0
%{_includedir}/quazip5/ %{_includedir}/quazip5/
%{_libdir}/libquazip5.so %{_libdir}/libquazip5.so
%{_datadir}/cmake/Modules/FindQuaZip5.cmake %{_datadir}/cmake/Modules/FindQuaZip5.cmake
%endif
%if %{with qt6}
%files qt6 %files qt6
%doc NEWS.txt README.md %doc NEWS.txt README.md
%license COPYING %license COPYING
@ -213,6 +266,7 @@ export QT_ENABLE_REGEXP_JIT=0
# qt6-qtbase-devel currently doesn't provide pkgconfig(Qt6Core) # qt6-qtbase-devel currently doesn't provide pkgconfig(Qt6Core)
# https://bugreports.qt.io/browse/QTBUG-86080 # https://bugreports.qt.io/browse/QTBUG-86080
%exclude %{_libdir}/pkgconfig/quazip1-qt6.pc %exclude %{_libdir}/pkgconfig/quazip1-qt6.pc
%endif
%changelog %changelog

Loading…
Cancel
Save