File QtPdCom1.spec of Package QtPdCom1

#----------------------------------------------------------------------------
#
# Copyright (C) 2009-2022  Florian Pose <fp@igh.de>
#                    2022  Bjarne von Horn <vh@igh.de>
#
# This file is part of the QtPdCom library.
#
# The QtPdCom library is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# The QtPdCom library is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
# License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with the QtPdCom Library. If not, see <http://www.gnu.org/licenses/>.
#
#----------------------------------------------------------------------------

%define projectname QtPdCom1
%define soversion 3

%define libname QtPdCom1
%define package_headers 1

Version: 0
Release: 0

Name: libQtPdCom1-%{soversion}
Summary: Process data communication library for Qt
License: LGPL-3.0+
Vendor: Ingenieurgemeinschaft IgH GmbH
Group: Productivity/Other
URL: https://gitlab.com/etherlab.org/qtpdcom
Source: %{projectname}-%{version}.tar.bz2

%{echo: suse_version is %{?suse_version}}
%{echo: sle_version is %{?sle_version}}
%{echo: is_opensuse is %{?is_opensuse}}

BuildRequires: fdupes
BuildRequires: libpdcom5-devel
BuildRequires: gcc-c++ cmake
BuildRequires: doxygen graphviz
BuildRequires: python3 python3-PyYAML

%if 0%{?fedora}
BuildRequires: qt5-qttools-devel
BuildRequires: qt5-qtbase-devel
BuildRequires: qt5-rpm-macros
%define _libqt5_docdir %_qt5_docdir
%else
BuildRequires: libqt5-qttools-devel
BuildRequires: libQt5Core-devel
BuildRequires: libQt5Gui-devel
BuildRequires: libQt5Network-devel
BuildRequires: libQt5Xml-devel
BuildRequires: libqt5-qtbase-common-devel
%endif

#----------------------------------------------------------------------------
# Main Package
#----------------------------------------------------------------------------

%description
This is a Qt5 implementation of the PdCom 5 interface, containing a
PdCom::Process class implementation using Qt's network layer. ScalarSubscriber
and ScalarVariable classes are included to provide process data access via
signals and slots. Messaging ist supported via the MessageModel class.

#----------------------------------------------------------------------------
# Development package
#----------------------------------------------------------------------------

%package -n lib%{libname}-devel

Summary: Development files for Applications using %{libname}
Group: Development/Libraries/C and C++
Requires: lib%{libname}-%{soversion} = %{version}
Requires: libpdcom5-devel
Requires: lib%{projectname}-headers = %{version}

%description -n lib%{libname}-devel
This is a Qt5 implementation of the PdCom 5 interface, containing a
PdCom::Process class implementation using Qt's network layer. ScalarSubscriber
and ScalarVariable classes are included to provide process data access via
signals and slots. Messaging ist supported via the MessageModel class.

%if 0%{?package_headers}
#----------------------------------------------------------------------------
# Headers package
#----------------------------------------------------------------------------

%package -n lib%{projectname}-headers

Summary: Headers for Applications using %{libname}
Group: Development/Libraries/C and C++
Requires: libpdcom5-devel
BuildArch: noarch

%description -n lib%{projectname}-headers
This is a Qt5/Qt6 implementation of the PdCom 5 interface, containing a
PdCom::Process class implementation using Qt's network layer. ScalarSubscriber
and ScalarVariable classes are included to provide process data access via
signals and slots. Messaging ist supported via the MessageModel class.


#----------------------------------------------------------------------------
# Development documentation package
#----------------------------------------------------------------------------
%package -n lib%{projectname}-doc
Summary:        Documentation for %{libname}
Group:          System/Libraries
BuildArch:      noarch

%description -n lib%{projectname}-doc
Doxygen-generated API documentation for %{projectname}

%endif
#----------------------------------------------------------------------------

%prep
%setup -q -n %{projectname}-%{version}

#----------------------------------------------------------------------------

%build

pushd .
%cmake -DVERSION_HASH=%{version} \
    -DGENERATE_QHP=1 \
    -DUSE_SYMBOL_VERSIONING=1
%cmake_build
popd
doxygen

#----------------------------------------------------------------------------

%install

pushd .
%cmake_install
popd

%if 0%{?package_headers}
# headers are provided elsewhere
mv doc/html .
install -d %buildroot%{_libqt5_docdir}
cp -v doc/qch/*.qch %buildroot%{_libqt5_docdir}/
%fdupes -s html
%else
rm -r %{buildroot}/%{_includedir}
rm -r doc/html doc/qch
%endif

%fdupes -s %buildroot/%_prefix

#----------------------------------------------------------------------------

%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig

%files

%defattr(-,root,root)
%doc AUTHORS COPYING NEWS README.md
%_libdir/lib%{libname}.so.*

%if 0%{?package_headers}
%files -n lib%{projectname}-headers
%defattr(-,root,root)
%_includedir/%{projectname}
%_includedir/%{projectname}.h

%files -n lib%{projectname}-doc
%defattr(-,root,root)
%doc html
%doc %{_libqt5_docdir}/QtPdCom-*.qch
%endif

%files -n lib%{libname}-devel
%defattr(-,root,root)
%_libdir/cmake/%{libname}
%_libdir/lib%{libname}.so

#----------------------------------------------------------------------------

%changelog
* Fri Dec 15 2023 Bjarne von Horn
- Split headers from devel package for Qt6 support.
* Fri Jan 06 2023 Bjarne von Horn
- Fedora support
* Fri Nov 25 2022 Florian Pose
- Taken from QtPdWidgets2:pdcom

#----------------------------------------------------------------------------
openSUSE Build Service is sponsored by