File cutelyst3-qt6.spec of Package cutelyst3-qt6

#
# spec file for package cutelyst3-qt6
#
# Copyright (c) 2015-2025 SUSE LLC
# Copyright (c) 2015-2025 Buschmann <buschmann23@opensuse.org>
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via http://bugs.opensuse.org/

# See also http://en.opensuse.org/openSUSE:Specfile_guidelines

%bcond_without tests
%bcond_without docs
%bcond_without jemalloc
%bcond_without brotli
%bcond_without zopfli
%bcond_without memcached
%bcond_without pwquality
%bcond_without clearsilver
%bcond_without cutelee
%bcond_without simplemail
%bcond_without apparmor

%{?!__cmake_builddir:%global __cmake_builddir %{_vpath_builddir}}

%if 0%{?suse_version}
%define _the_build_dir %{__builddir}
%else
%define _the_build_dir %{__cmake_builddir}
%endif

%{?!mklibname:%global mklibname(ds) lib%{1}%{?2:%{2}}%{?3:_%{3}}%{-s:-static}%{-d:-devel}}

%define _tarname cutelyst
%define _sonum 3
%define _sonumSep -
%if 0%{?mageia}
%define _sonumSep _
%endif

%define _majorVersion 3
%define _qtMajVersion 6
%define _qtMinVersion 6.2
%define _cmakeMinVersion 3.16

%define _cbasename Cutelyst%{_majorVersion}Qt%{_qtMajVersion}

%define _libname %{mklibname %{_cbasename}}
%define _pluginAuth %{mklibname %{_cbasename}Authentication}
%define _pluginSession %{mklibname %{_cbasename}Session}
%define _pluginStaticsimple %{mklibname %{_cbasename}StaticSimple}
%define _pluginStaticCompressed %{mklibname %{_cbasename}StaticCompressed}
%define _pluginUtilsSql %{mklibname %{_cbasename}UtilsSql}
%define _pluginUtilsPagination %{mklibname %{_cbasename}UtilsPagination}
%define _pluginStatusMessage %{mklibname %{_cbasename}StatusMessage}
%define _pluginValidator %{mklibname %{_cbasename}UtilsValidator}
%define _pluginMemcached %{mklibname %{_cbasename}Memcached}
%define _pluginMemcachedSession %{mklibname %{_cbasename}MemcachedSessionStore}
%define _pluginCsrfProtection %{mklibname %{_cbasename}CSRFProtection}
%define _pluginLangSelect %{mklibname %{_cbasename}UtilsLangSelect}
%define _pluginUa %{mklibname %{_cbasename}UserAgent}
%define _viewJson %{mklibname %{_cbasename}ViewJson}
%define _viewEmail %{mklibname %{_cbasename}ViewEmail}
%define _viewClearsilver %{mklibname %{_cbasename}ViewClearSilver}
%define _viewCutelee %{mklibname %{_cbasename}ViewCutelee}
%define _server %{mklibname %{_cbasename}Server}
%define _eventloop %{mklibname %{_cbasename}EventLoopEpoll}

%define _doc_base_dir %{_qt6_docdir}
%define _cracklib_dict_pkg cracklib-dicts
%define _translatlations_dir %{_datadir}/cutelyst%{_sonum}-qt%{_qtMajVersion}/translations
%define _memcached_bin %{_bindir}/memcached
%define _ninjaPkg ninja

%if 0%{?suse_version}
%define _cracklib_dict_pkg cracklib-dict-full
%if 0%{?suse_version} <= 1500
%define _memcached_bin %{_sbindir}/memcached
%endif
%endif

%if 0%{?fedora}
%define _ninjaPkg ninja-build
%endif

Name:           cutelyst3-qt6
Version:        3.9.1~git
Release:        1
Summary:        Development Tools Command Line Utility
License:        BSD-3-Clause
Group:          Development/Tools/Other
Url:            http://www.cutelyst.org
Source0:        %{_tarname}-%{version}.tar.xz
Source1:        %{name}-rpmlintrc
Source2:        %{name}-apparmor.in
# PATCH-FIX-OPENSUSE 0008-fix-clearsilver-0.11.0.patch
Patch8:         0008-fix-clearsilver-0.11.0.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildRequires:  cmake >= %{_cmakeMinVersion}
BuildRequires:  pkgconfig
BuildRequires:  %{_ninjaPkg}
BuildRequires:  cmake(Qt%{_qtMajVersion}Core) >= %{_qtMinVersion}
BuildRequires:  cmake(Qt%{_qtMajVersion}Network) >= %{_qtMinVersion}
BuildRequires:  cmake(Qt%{_qtMajVersion}Sql) >= %{_qtMinVersion}
BuildRequires:  cmake(Qt%{_qtMajVersion}LinguistTools) >= %{_qtMinVersion}
%if 0%{?fedora}
BuildRequires:  qt6-rpm-macros
%endif
Recommends:     %{name}-lang

%if 0%{with apparmor}
BuildRequires:  apparmor-abstractions
%endif

%if 0%{with clearsilver}
BuildRequires:  clearsilver-devel
%endif

%if 0%{with cutelee}
BuildRequires:  cmake(Cutelee6Qt%{_qtMajVersion}) >= 6.0.0
%endif

%if 0%{with simplemail}
BuildRequires:  cmake(SimpleMail2Qt%{_qtMajVersion}) >= 2.0.0
%endif

%if 0%{with pwquality}
BuildRequires:  pkgconfig(pwquality)
%endif

%if 0%{with jemalloc}
BuildRequires:  pkgconfig(jemalloc)
%endif

%if 0%{with memcached}
BuildRequires:  pkgconfig(libmemcached)
%endif

%if 0%{with zopfli}
BuildRequires:  cmake(Zopfli)
%endif
%if 0%{with brotli}
BuildRequires:  pkgconfig(libbrotlienc)
%endif

%if 0%{with tests}
BuildRequires:  %{_cracklib_dict_pkg}
BuildRequires:  cmake(Qt%{_qtMajVersion}Test) >= %{_qtMinVersion}
%if 0%{with memcached}
BuildRequires:  memcached
%endif
%endif

%if 0%{with docs}
BuildRequires:  doxygen graphviz
BuildRequires:  cmake(Qt%{_qtMajVersion}Help)
BuildRequires:  cmake(Qt%{_qtMajVersion}Tools)

%if 0%{?suse_version}
BuildRequires:  graphviz-gd
BuildRequires:  gnu-free-fonts
BuildRequires:  qt6-base-docs-html qt6-base-docs-qch
%endif

%if 0%{?fedora}
BuildRequires:  graphviz-gd
BuildRequires:  gnu-free-sans-fonts
#TODO: add packages containing docs and tags if available
%endif

%if 0%{?mageia}
BuildRequires:  gnu-free-sans-fonts
#TODO: add packages containing docs and tags if available
%endif
%endif

%description
Cutelyst%{_majorVersion} CLI tool providing support for developing cutelyst applications.

%if 0%{?suse_version}
%lang_package -n %{name}
%else
%package -n %{name}-lang
Summary:            Translations for package %{name}
Group:              System/Localization
Requires:           %{name} = %{version}
Provides:           %{name}-lang-all = %{version}
BuildArch:          noarch
%description -n %{name}-lang
Provides translations for the \"%{name}\" package.
%endif


%package devel
Summary:        Cutelyst%{_majorVersion} Web Framework - Development Files
Group:          Development/Libraries/C and C++
Requires:       cmake >= %{_cmakeMinVersion}
Requires:       %{name}
Requires:       cutelystd%{_majorVersion}-qt%{_qtMajVersion}
Requires:       %{name}-plugins = %{version}-%{release}
Requires:       %{_libname}%{_sonumSep}%{_sonum} = %{version}-%{release}
Requires:       %{_pluginAuth}%{_sonum} = %{version}-%{release}
Requires:       %{_pluginSession}%{_sonum} = %{version}-%{release}
Requires:       %{_pluginStaticsimple}%{_sonum} = %{version}-%{release}
Requires:       %{_pluginStaticCompressed}%{_sonum} = %{version}-%{release}
Requires:       %{_pluginUtilsSql}%{_sonum} = %{version}-%{release}
Requires:       %{_pluginUtilsPagination}%{_sonum} = %{version}-%{release}
Requires:       %{_pluginStatusMessage}%{_sonum} = %{version}-%{release}
Requires:       %{_pluginValidator}%{_sonum} = %{version}-%{release}
%if 0%{with memcached}
Requires:       %{_pluginMemcached}%{_sonum} = %{version}-%{release}
Requires:       %{_pluginMemcachedSession}%{_sonum} = %{version}-%{release}
%endif
Requires:       %{_pluginCsrfProtection}%{_sonum} = %{version}-%{release}
Requires:       %{_pluginLangSelect}%{_sonum} = %{version}-%{release}
Requires:       %{_pluginUa}%{_sonum} = %{version}-%{release}
Requires:       %{_viewJson}%{_sonum} = %{version}-%{release}
%if 0%{with simplemail}
Requires:       %{_viewEmail}%{_sonum} = %{version}-%{release}
%endif
%if 0%{with clearsilver}
Requires:       %{_viewClearsilver}%{_sonum} = %{version}-%{release}
%endif
%if 0%{with cutelee}
Requires:       %{_viewCutelee}%{_sonum} = %{version}-%{release}
%endif
Requires:       %{_server}%{_sonum} = %{version}-%{release}
Requires:       %{_eventloop}%{_sonum} = %{version}-%{release}
%if 0%{with docs}
Suggests:       %{name}-docs-qch
%endif
Requires:       cmake(Qt%{_qtMajVersion}Core) >= %{_qtMinVersion}
Requires:       cmake(Qt%{_qtMajVersion}Network) >= %{_qtMinVersion}
Requires:       cmake(Qt%{_qtMajVersion}Sql) >= %{_qtMinVersion}

%description devel
Development and header files for the Cutelyst%{_majorVersion} web framework and core plugins.


%package -n cutelystd%{_majorVersion}-qt%{_qtMajVersion}
Summary:        Cutelyst%{_majorVersion} Web Service Gateway Interface
Group:          Productivity/Networking/Web/Servers
Recommends:     cutelystd%{_majorVersion}-qt%{_qtMajVersion}-lang
%if 0%{with apparmor}
Requires:       apparmor-abstractions
%endif

%description -n cutelystd%{_majorVersion}-qt%{_qtMajVersion}
Fast WSGI engine (HTTP 1.1 and FastCGI both with Pipelining and Keep-Alive support) for Cutelyst%{_majorVersion} applications.

%if 0%{?suse_version}
%lang_package -n cutelystd%{_majorVersion}-qt%{_qtMajVersion}
%else
%package -n cutelystd%{_majorVersion}-qt%{_qtMajVersion}-lang
Summary:            Translations for package cutelystd%{_majorVersion}-qt%{_qtMajVersion}
Group:              System/Localization
Requires:           cutelystd%{_majorVersion}-qt%{_qtMajVersion} = %{version}
Provides:           cutelystd%{_majorVersion}-qt%{_qtMajVersion}-lang-all = %{version}
BuildArch:          noarch
%description -n cutelystd%{_majorVersion}-qt%{_qtMajVersion}-lang
Provides translations for the \"cutelystd%{_majorVersion}-qt%{_qtMajVersion}\" package.
%endif

%package -n %{_libname}%{_sonumSep}%{_sonum}
Summary:        Cutelyst%{_majorVersion} Web Framework Core Library
Group:          System/Libraries
Recommends:     %{name}-doc
Recommends:     %{_libname}%{_sonumSep}%{_sonum}-lang

%description -n %{_libname}%{_sonumSep}%{_sonum}
The Cutelyst%{_majorVersion} web framework core library.

%if 0%{?suse_version}
%lang_package -n %{_libname}%{_sonumSep}%{_sonum}
%else
%package -n %{_libname}%{_sonumSep}%{_sonum}-lang
Summary:            Translations for package %{_libname}%{_sonumSep}%{_sonum}
Group:              System/Localization
Requires:           %{_libname}%{_sonumSep}%{_sonum} = %{version}
Provides:           %{_libname}%{_sonumSep}%{_sonum}-lang-all = %{version}
BuildArch:          noarch
%description -n %{_libname}%{_sonumSep}%{_sonum}-lang
Provides translations for the \"%{_libname}%{_sonumSep}%{_sonum}\" package.
%endif


%package -n %{_pluginAuth}%{_sonum}
Summary:        Authentication Plugin for Cutelyst%{_majorVersion}
Group:          System/Libraries

%description -n %{_pluginAuth}%{_sonum}
Authentication plugin for the Cutelyst%{_majorVersion} web framework.


%package -n %{_pluginSession}%{_sonum}
Summary:        Session Plugin for Cutelyst%{_majorVersion}
Group:          System/Libraries
Recommends:     %{name}-common

%description -n %{_pluginSession}%{_sonum}
Session plugin for the Cutelyst%{_majorVersion} web framework.


%package -n %{_pluginStaticsimple}%{_sonum}
Summary:        Simple Static Plugin for Cutelyst%{_majorVersion}
Group:          System/Libraries

%description -n %{_pluginStaticsimple}%{_sonum}
Simple static files plugin for the Cutelyst%{_majorVersion} web framework.


%package -n %{_pluginStaticCompressed}%{_sonum}
Summary:        Compressed Static Plugin for Cutelyst%{_majorVersion}
Group:          System/Libraries

%description -n %{_pluginStaticCompressed}%{_sonum}
This plugin for the Cutelyst%{_majorVersion} web framework can deliver static files
compressed and cached on the fly.


%package -n %{_pluginUtilsSql}%{_sonum}
Summary:        SQL Utils Plugin for Cutelyst%{_majorVersion}
Group:          System/Libraries

%description -n %{_pluginUtilsSql}%{_sonum}
SQL utils plugin for the Cutelyst%{_majorVersion} web framework. Provides helper methods
for database access and to provide SQL queries into something userful for templates.


%package -n %{_pluginUtilsPagination}%{_sonum}
Summary:        Pagination Plugin for Cutelyst%{_majorVersion}
Group:          System/Libraries

%description -n %{_pluginUtilsPagination}%{_sonum}
Pagination plugin for the Cutelyst%{_majorVersion} web framework.


%package -n %{_pluginStatusMessage}%{_sonum}
Summary:        Status Message Plugin for Cutelyst%{_majorVersion}
Group:          System/Libraries

%description -n %{_pluginStatusMessage}%{_sonum}
Status message plugin for the Cutelyst%{_majorVersion} web framework.


%package -n %{_pluginValidator}%{_sonum}
Summary:        Validator Plugin for Cutelyst%{_majorVersion}
Group:          System/Libraries
Recommends:     %{_pluginValidator}%{_sonum}

%description -n %{_pluginValidator}%{_sonum}
Input validation plugin for the Cutelyst%{_majorVersion} web framework.

%if 0%{?suse_version}
%lang_package -n %{_pluginValidator}%{_sonum}
%else
%package -n %{_pluginValidator}%{_sonum}-lang
Summary:            Translations for package %{_pluginValidator}%{_sonum}
Group:              System/Localization
Requires:           %{_pluginValidator}%{_sonum} = %{version}
Provides:           %{_pluginValidator}%{_sonum}-lang-all = %{version}
BuildArch:          noarch
%description -n %{_pluginValidator}%{_sonum}-lang
Provides translations for the \"%{_pluginValidator}%{_sonum}\" package.
%endif


%if 0%{with memcached}
%package -n %{_pluginMemcached}%{_sonum}
Summary:        Memcached Plugin for Cutelyst%{_majorVersion}
Group:          System/Libraries
Recommends:     %{_pluginMemcached}%{_sonum}-lang
Recommends:     %{name}-common

%description -n %{_pluginMemcached}%{_sonum}
Memcached plugin for the Cutelyst%{_majorVersion} web framework.

%if 0%{?suse_version}
%lang_package -n %{_pluginMemcached}%{_sonum}
%else
%package -n %{_pluginMemcached}%{_sonum}-lang
Summary:            Translations for package %{_pluginMemcached}%{_sonum}
Group:              System/Localization
Requires:           %{_pluginMemcached}%{_sonum} = %{version}
Provides:           %{_pluginMemcached}%{_sonum}-lang-all = %{version}
BuildArch:          noarch
%description -n %{_pluginMemcached}%{_sonum}-lang
Provides translations for the \"%{_pluginMemcached}%{_sonum}\" package.
%endif

%package -n %{_pluginMemcachedSession}%{_sonum}
Summary:        Memcached Session Store Plugin for Cutelyst%{_majorVersion}
Group:          System/Libraries
Recommends:     %{name}-common

%description -n %{_pluginMemcachedSession}%{_sonum}
Memcached session store plugin for the Cutelyst%{_majorVersion} web framework.
%endif


%package -n %{_pluginCsrfProtection}%{_sonum}
Summary:        CSRF Protection Plugin for Cutelyst%{_majorVersion}
Group:          System/Libraries
Recommends:     %{_pluginCsrfProtection}%{_sonum}-lang
Recommends:     %{name}-common

%description -n %{_pluginCsrfProtection}%{_sonum}
Cutelyst%{_majorVersion} plugin to protect input forms against Cross Site Request Forgery (CSRF) attacks.


%if 0%{?suse_version}
%lang_package -n %{_pluginCsrfProtection}%{_sonum}
%else
%package -n %{_pluginCsrfProtection}%{_sonum}-lang
Summary:            Translations for package %{_pluginCsrfProtection}%{_sonum}
Group:              System/Localization
Requires:           %{_pluginCsrfProtection}%{_sonum} = %{version}
Provides:           %{_pluginCsrfProtection}%{_sonum}-lang-all = %{version}
BuildArch:          noarch
%description -n %{_pluginCsrfProtection}%{_sonum}-lang
Provides translations for the \"%{_pluginCsrfProtection}%{_sonum}\" package.
%endif


%package -n %{_pluginLangSelect}%{_sonum}
Summary:        User Language Selection Plugin for Cutelyst%{_majorVersion}
Group:          System/Libraries

%description -n %{_pluginLangSelect}%{_sonum}
The LangSelect plugin for the Cutelyst%{_majorVersion} web framework can automatically select
a supported language that best fits the user's language settings, either set
somewhere in your application or by analyzing the Accept-Language HTTP header.


%package -n %{_pluginUa}%{_sonum}
Summary:        User Agent Plugin for Cutelyst%{_majorVersion}
Group:          System/Libraries

%description -n %{_pluginUa}%{_sonum}
The UserAgent plugin provides a helper singleton so that you have a thread_local
QNetworkAccessManager with static methods to do more common REST tasks like
sending a QJsonObject.


%package -n %{_viewJson}%{_sonum}
Summary:        JSON View Plugin for Cutelyst%{_majorVersion}
Group:          System/Libraries

%description -n %{_viewJson}%{_sonum}
JSON view plugin for the Cutelyst%{_majorVersion} web framework.


%if 0%{with simplemail}
%package -n %{_viewEmail}%{_sonum}
Summary:        Email View Plugin for Cutelyst%{_majorVersion}
Group:          System/Libraries

%description -n %{_viewEmail}%{_sonum}
Email view plugin for the Cutelyst%{_majorVersion} web framework.
%endif


%if 0%{with clearsilver}
%package -n %{_viewClearsilver}%{_sonum}
Summary:        Clearsilver View for Cutelyst2
Group:          System/Libraries

%description -n %{_viewClearsilver}%{_sonum}
Clearsilver HTML template engine plugin for the Cutelyst2 web framework.
%endif


%if 0%{with cutelee}
%package -n %{_viewCutelee}%{_sonum}
Summary:        Cutelee View for Cutelyst%{_majorVersion}
Group:          System/Libraries
Recommends:     %{_viewCutelee}%{_sonum}-lang

%description -n %{_viewCutelee}%{_sonum}
Cutelee Qt string template library plugin for Cutelyst%{_majorVersion} web framework.

%if 0%{?suse_version}
%lang_package -n %{_viewCutelee}%{_sonum}
%else
%package -n %{_viewCutelee}%{_sonum}-lang
Summary:            Translations for package %{_viewCutelee}%{_sonum}
Group:              System/Localization
Requires:           %{_viewCutelee}%{_sonum} = %{version}
Provides:           %{_viewCutelee}%{_sonum}-lang-all = %{version}
BuildArch:          noarch
%description -n %{_viewCutelee}%{_sonum}-lang
Provides translations for the \"%{_viewCutelee}%{_sonum}\" package.
%endif
%endif


%package -n %{_server}%{_sonum}
Summary:        Cutelyst%{_majorVersion} WSGI Library
Group:          System/Libraries

%description -n %{_server}%{_sonum}
WSGI library for the Cutelyst%{_majorVersion} web framework.


%package -n %{_eventloop}%{_sonum}
Summary:        Cutelyst%{_majorVersion} Epoll Event Loop
Group:          System/Libraries
AutoReqProv:    yes

%description -n %{_eventloop}%{_sonum}
Cutelyst%{_majorVersion} event loop based on epoll for linux systems.


%if 0%{with docs}
%package docs-qch
Summary:        Cutelyst%{_majorVersion} API Documentation in QCH Format
Group:          Documentation/Other
BuildArch:      noarch
Provides:       %{name}-devel-doc = %{version}-%{release}
Obsoletes:      %{name}-devel-doc < %{version}-%{release}
Provides:       %{name}-devel-docs-qch = %{version}-%{release}
Obsoletes:      %{name}-devel-docs-qch < %{version}-%{release}
%if 0%{?suse_version}
Recommends:     qt6-base-docs-qch
%endif
%if 0%{?fedora}
#TODO: add packages containing docs if available
# Recommends:     qt5-qtbase-doc
%endif
%if 0%{?mageia}
#TODO: add packages containing docs if available
# Recommends:     qtbase5-doc
%endif

%description docs-qch
API documentation files for the Cutelyst%{_majorVersion} web framework. This includes
the QCH file for the QtHelp system.


%package docs-html
Summary:        Cutelyst%{_majorVersion} API Documentation in HTML Format
Group:          Documentation/HTML
BuildArch:      noarch
Provides:       %{name}-devel-doc-html = %{version}-%{release}
Obsoletes:      %{name}-devel-doc-html < %{version}-%{release}
Provides:       %{name}-devel-docs-html = %{version}-%{release}
Obsoletes:      %{name}-devel-docs-html < %{version}-%{release}
Provides:       %{name}-devel-doc-tags = %{version}-%{release}
Obsoletes:      %{name}-devel-doc-tags < %{version}-%{release}
Provides:       %{name}-devel-docs-tags = %{version}-%{release}
Obsoletes:      %{name}-devel-docs-tags < %{version}-%{release}
%if 0%{?suse_version}
Recommends:     qt6-base-docs-html
%endif
%if 0%{?fedora}
#TODO: add packages containing docs if available
# Recommends:     qt5-qtbase-doc
%endif
%if 0%{?mageia}
#TODO: add packages containing docs if available
# Recommends:     qtbase5-doc
%endif

%description docs-html
API documentation files for the Cutelyst%{_majorVersion} web framework. This includes
HTML files.
%endif


%package common
Summary:        Cutelyst%{_majorVersion} Web Framework - Common Files
Group:          Documentation/Man
BuildArch:      noarch
Provides:       %{name}-doc = %{version}-%{release}
Obsoletes:      %{name}-doc < %{version}-%{release}
Provides:       %{name}-docs = %{version}-%{release}
Obsoletes:      %{name}-docs < %{version}-%{release}

%description common
Common files for the Cutelyst%{_majorVersion} Web Framework like man pages for configuration
options for plugins.


%package plugins
Summary:        Cutelyst%{_majorVersion} Action Plugins
Group:          System/Libraries

%description plugins
Cutelyst%{_majorVersion} web framework plugins for the following actions: REST, RenderView, RoleACL


%prep
%autosetup -N -n %{_tarname}-%{version}
%if 0%{?suse_version}
%patch -P8 -p1
%endif


%build
%cmake_qt6 \
%if 0%{with tests}
    -DBUILD_TESTS:BOOL=ON \
%endif
%if 0%{with docs}
    -DBUILD_DOCS:BOOL=ON \
    -DBUILD_DOCS_QUIET:BOOL=ON \
    -DBUILD_DOCS_TIMESTAMP:BOOL=OFF \
%endif
%if 0%{with simplemail}
    -DPLUGIN_VIEW_EMAIL:BOOL=ON \
%endif
%if 0%{with cutelee}
    -DPLUGIN_VIEW_CUTELEE:BOOL=ON \
%endif
%if 0%{with clearsilver}
    -DPLUGIN_VIEW_CLEARSILVER:BOOL=ON \
%endif
%if 0%{with pwquality}
    -DPLUGIN_VALIDATOR_PWQUALITY:BOOL=ON \
%endif
%if 0%{with jemalloc}
    -USE_JEMALLOC:BOOL=ON \
%endif
%if 0%{with memcached}
    -DPLUGIN_MEMCACHED:BOOL=ON \
%endif
    -DPLUGIN_STATICCOMPRESSED:BOOL=ON \
%if 0%{with zopfli}
    -DPLUGIN_STATICCOMPRESSED_ZOPFLI:BOOL=ON \
%endif
%if 0%{with brotli}
    -DPLUGIN_STATICCOMPRESSED_BROTLI:BOOL=ON \
%endif
    -DPLUGIN_CSRFPROTECTION:BOOL=ON

%if 0%{?suse_version}
%qt6_build
%else
%cmake_build
%endif

%if 0%{with docs}
%if 0%{?suse_version}
%qt6_build_docs
%else
%cmake_build -t docs
%endif
%endif

%install
%if 0%{?suse_version}
%qt6_install
%else
%cmake_install
%endif

mkdir -p %{buildroot}%{_libdir}/%{name}-apps
%if 0%{with docs}
  mkdir -p %{buildroot}%{_doc_base_dir}/cutelyst%{_majorVersion}
  cp -r %{_the_build_dir}/htmldocs/* %{buildroot}%{_doc_base_dir}/cutelyst%{_majorVersion}
  cp %{_the_build_dir}/cutelyst%{_majorVersion}.tags %{buildroot}%{_doc_base_dir}/cutelyst%{_majorVersion}
  cp %{_the_build_dir}/cutelyst%{_majorVersion}.qch %{buildroot}%{_doc_base_dir}
%endif
  mkdir -p %{buildroot}%{_datadir}/qtcreator/templates/wizards/projects/%{name}
  cp -r qtcreator/cutelyst/projects/* %{buildroot}%{_datadir}/qtcreator/templates/wizards/projects/%{name}
  mkdir -p %{buildroot}%{_datadir}/qtcreator/templates/wizards/classes/%{name}-controller
  cp -r qtcreator/cutelyst/classes/* %{buildroot}%{_datadir}/qtcreator/templates/wizards/classes/%{name}-controller

%if 0%{with apparmor}
mkdir -p %{buildroot}/etc/apparmor.d/abstractions
sed 's!@CUTELYST_TRANSLATION_FILES_PATH@!%{_translatlations_dir}!' %{SOURCE2} > %{buildroot}%{_sysconfdir}/apparmor.d/abstractions/%{name}
%endif

%if 0%{with tests}
%check
%ctest
%endif

%post -n cutelystd%{_majorVersion}-qt%{_qtMajVersion} -p /sbin/ldconfig
%postun -n cutelystd%{_majorVersion}-qt%{_qtMajVersion} -p /sbin/ldconfig

%post -n %{_libname}%{_sonumSep}%{_sonum} -p /sbin/ldconfig
%postun -n %{_libname}%{_sonumSep}%{_sonum} -p /sbin/ldconfig

%post -n %{_pluginAuth}%{_sonum} -p /sbin/ldconfig
%postun -n %{_pluginAuth}%{_sonum} -p /sbin/ldconfig

%post -n %{_pluginSession}%{_sonum} -p /sbin/ldconfig
%postun -n %{_pluginSession}%{_sonum} -p /sbin/ldconfig

%post -n %{_pluginStaticsimple}%{_sonum} -p /sbin/ldconfig
%postun -n %{_pluginStaticsimple}%{_sonum} -p /sbin/ldconfig

%post -n %{_pluginStaticCompressed}%{_sonum} -p /sbin/ldconfig
%postun -n %{_pluginStaticCompressed}%{_sonum} -p /sbin/ldconfig

%post -n %{_pluginUtilsSql}%{_sonum} -p /sbin/ldconfig
%postun -n %{_pluginUtilsSql}%{_sonum} -p /sbin/ldconfig

%post -n %{_pluginUtilsPagination}%{_sonum} -p /sbin/ldconfig
%postun -n %{_pluginUtilsPagination}%{_sonum} -p /sbin/ldconfig

%post -n %{_pluginStatusMessage}%{_sonum} -p /sbin/ldconfig
%postun -n %{_pluginStatusMessage}%{_sonum} -p /sbin/ldconfig

%post -n %{_pluginValidator}%{_sonum} -p /sbin/ldconfig
%postun -n %{_pluginValidator}%{_sonum} -p /sbin/ldconfig

%if 0%{with memcached}
%post -n %{_pluginMemcached}%{_sonum} -p /sbin/ldconfig
%postun -n %{_pluginMemcached}%{_sonum} -p /sbin/ldconfig

%post -n %{_pluginMemcachedSession}%{_sonum} -p /sbin/ldconfig
%postun -n %{_pluginMemcachedSession}%{_sonum} -p /sbin/ldconfig
%endif

%post -n %{_pluginCsrfProtection}%{_sonum} -p /sbin/ldconfig
%postun -n %{_pluginCsrfProtection}%{_sonum} -p /sbin/ldconfig

%post -n %{_pluginLangSelect}%{_sonum} -p /sbin/ldconfig
%postun -n %{_pluginLangSelect}%{_sonum} -p /sbin/ldconfig

%post -n %{_pluginUa}%{_sonum} -p /sbin/ldconfig
%postun -n %{_pluginUa}%{_sonum} -p /sbin/ldconfig

%post -n %{_viewJson}%{_sonum} -p /sbin/ldconfig
%postun -n %{_viewJson}%{_sonum} -p /sbin/ldconfig

%if 0%{with simplemail}
%post -n %{_viewEmail}%{_sonum} -p /sbin/ldconfig
%postun -n %{_viewEmail}%{_sonum} -p /sbin/ldconfig
%endif

%if 0%{with clearsilver}
%post -n %{_viewClearsilver}%{_sonum} -p /sbin/ldconfig
%postun -n %{_viewClearsilver}%{_sonum} -p /sbin/ldconfig
%endif

%if 0%{with cutelee}
%post -n %{_viewCutelee}%{_sonum} -p /sbin/ldconfig
%postun -n %{_viewCutelee}%{_sonum} -p /sbin/ldconfig
%endif

%post -n %{_server}%{_sonum} -p /sbin/ldconfig
%postun -n %{_server}%{_sonum} -p /sbin/ldconfig

%post -n %{_eventloop}%{_sonum} -p /sbin/ldconfig
%postun -n %{_eventloop}%{_sonum} -p /sbin/ldconfig


%files
%{_bindir}/%{name}
%{_mandir}/man1/cutelyst%{_majorVersion}-qt%{_qtMajVersion}.1%{ext_man}

%files -n %{name}-lang
%lang(de) %{_translatlations_dir}/cutelystcmd.de.qm
%lang(en) %{_translatlations_dir}/cutelystcmd.en.qm

%files -n cutelystd%{_majorVersion}-qt%{_qtMajVersion}
%{_bindir}/cutelystd%{_majorVersion}-qt%{_qtMajVersion}
%dir %{_libdir}/%{name}-apps
%{_mandir}/man1/cutelystd%{_majorVersion}-qt%{_qtMajVersion}.1%{ext_man}
%if 0%{with apparmor}
%config(noreplace) %{_sysconfdir}/apparmor.d/abstractions/%{name}
%endif

%files -n cutelystd%{_majorVersion}-qt%{_qtMajVersion}-lang
%lang(de) %{_translatlations_dir}/cutelystserver.de.qm
%lang(en) %{_translatlations_dir}/cutelystserver.en.qm

%files -n %{_libname}%{_sonumSep}%{_sonum}
%license COPYING
%{_libdir}/lib%{_cbasename}.so.*

%files -n %{_libname}%{_sonumSep}%{_sonum}-lang
%dir %{_datadir}/%{name}
%dir %{_translatlations_dir}
%lang(de) %{_translatlations_dir}/cutelystcore.de.qm
%lang(en) %{_translatlations_dir}/cutelystcore.en.qm

%files -n %{_pluginAuth}%{_sonum}
%{_libdir}/lib%{_cbasename}Authentication.so.*

%files -n %{_pluginSession}%{_sonum}
%{_libdir}/lib%{_cbasename}Session.so.*

%files -n %{_pluginStaticsimple}%{_sonum}
%{_libdir}/lib%{_cbasename}StaticSimple.so.*

%files -n %{_pluginStaticCompressed}%{_sonum}
%{_libdir}/lib%{_cbasename}StaticCompressed.so.*

%files -n %{_pluginUtilsSql}%{_sonum}
%{_libdir}/lib%{_cbasename}UtilsSql.so.*

%files -n %{_pluginUtilsPagination}%{_sonum}
%{_libdir}/lib%{_cbasename}UtilsPagination.so.*

%files -n %{_pluginStatusMessage}%{_sonum}
%{_libdir}/lib%{_cbasename}StatusMessage.so.*

%files -n %{_pluginValidator}%{_sonum}
%{_libdir}/lib%{_cbasename}UtilsValidator.so.*

%files -n %{_pluginValidator}%{_sonum}-lang
%lang(de) %{_translatlations_dir}/plugin_utils_validator.de.qm
%lang(en) %{_translatlations_dir}/plugin_utils_validator.en.qm

%if 0%{with memcached}
%files -n %{_pluginMemcached}%{_sonum}
%{_libdir}/lib%{_cbasename}Memcached.so.*

%files -n %{_pluginMemcached}%{_sonum}-lang
%lang(de) %{_translatlations_dir}/plugin_memcached.de.qm
%lang(en) %{_translatlations_dir}/plugin_memcached.en.qm

%files -n %{_pluginMemcachedSession}%{_sonum}
%{_libdir}/lib%{_cbasename}MemcachedSessionStore.so.*
%endif

%files -n %{_pluginCsrfProtection}%{_sonum}
%{_libdir}/lib%{_cbasename}CSRFProtection.so.*

%files -n %{_pluginCsrfProtection}%{_sonum}-lang
%lang(de) %{_translatlations_dir}/plugin_csrfprotection.de.qm
%lang(en) %{_translatlations_dir}/plugin_csrfprotection.en.qm

%files -n %{_pluginLangSelect}%{_sonum}
%{_libdir}/lib%{_cbasename}UtilsLangSelect.so.*

%files -n %{_pluginUa}%{_sonum}
%{_libdir}/lib%{_cbasename}UserAgent.so.*

%files -n %{_viewJson}%{_sonum}
%{_libdir}/lib%{_cbasename}ViewJson.so.*

%if 0%{with simplemail}
%files -n %{_viewEmail}%{_sonum}
%{_libdir}/lib%{_cbasename}ViewEmail.so.*
%endif

%if 0%{with clearsilver}
%files -n %{_viewClearsilver}%{_sonum}
%{_libdir}/lib%{_cbasename}ViewClearSilver.so.*
%endif

%if 0%{with cutelee}
%files -n %{_viewCutelee}%{_sonum}
%{_libdir}/lib%{_cbasename}ViewCutelee.so.*

%files -n %{_viewCutelee}%{_sonum}-lang
%lang(de) %{_translatlations_dir}/plugin_view_cutelee.de.qm
%lang(en) %{_translatlations_dir}/plugin_view_cutelee.en.qm
%endif

%files -n %{_server}%{_sonum}
%{_libdir}/lib%{_cbasename}Server.so.*

%files -n %{_eventloop}%{_sonum}
%{_libdir}/lib%{_cbasename}EventLoopEpoll.so.*

%if 0%{with docs}
%files docs-qch
%{_doc_base_dir}/cutelyst%{_majorVersion}.qch

%files docs-html
%{_doc_base_dir}/cutelyst%{_majorVersion}
%endif

%files common
%{_mandir}/man5/%{_cbasename}Session.5%{ext_man}
%{_mandir}/man5/%{_cbasename}Memcached.5%{ext_man}
%{_mandir}/man5/%{_cbasename}MemcachedSessionStore.5%{ext_man}
%{_mandir}/man5/%{_cbasename}CSRFProtection.5%{ext_man}

%files plugins
%dir %{_libdir}/%{name}-plugins
%{_libdir}/%{name}-plugins/lib*.so

%files devel
%{_includedir}/%{name}
%{_libdir}/lib%{_cbasename}.so
%{_libdir}/lib%{_cbasename}Authentication.so
%{_libdir}/lib%{_cbasename}Session.so
%{_libdir}/lib%{_cbasename}StaticSimple.so
%{_libdir}/lib%{_cbasename}StaticCompressed.so
%{_libdir}/lib%{_cbasename}UtilsSql.so
%{_libdir}/lib%{_cbasename}UtilsPagination.so
%{_libdir}/lib%{_cbasename}StatusMessage.so
%{_libdir}/lib%{_cbasename}UtilsValidator.so
%if 0%{with memcached}
%{_libdir}/lib%{_cbasename}Memcached.so
%{_libdir}/lib%{_cbasename}MemcachedSessionStore.so
%endif
%{_libdir}/lib%{_cbasename}CSRFProtection.so
%{_libdir}/lib%{_cbasename}UtilsLangSelect.so
%{_libdir}/lib%{_cbasename}UserAgent.so
%{_libdir}/lib%{_cbasename}ViewJson.so
%if 0%{with simplemail}
%{_libdir}/lib%{_cbasename}ViewEmail.so
%endif
%if 0%{with clearsilver}
%{_libdir}/lib%{_cbasename}ViewClearSilver.so
%endif
%if 0%{with cutelee}
%{_libdir}/lib%{_cbasename}ViewCutelee.so
%endif
%{_libdir}/lib%{_cbasename}Server.so
%{_libdir}/lib%{_cbasename}EventLoopEpoll.so
%{_libdir}/pkgconfig/%{_cbasename}*.pc
%{_libdir}/cmake/%{_cbasename}
%dir %{_datadir}/qtcreator
%dir %{_datadir}/qtcreator/templates
%dir %{_datadir}/qtcreator/templates/wizards
%dir %{_datadir}/qtcreator/templates/wizards/projects
%{_datadir}/qtcreator/templates/wizards/projects/%{name}
%dir %{_datadir}/qtcreator/templates/wizards/classes
%{_datadir}/qtcreator/templates/wizards/classes/%{name}-controller
openSUSE Build Service is sponsored by