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