%bcond_with gcc

%global _rxlibdir /opt/rx/%{_lib}
%global _rxincludedir /opt/rx/include

Name:    como
Version: 0.1.0
Release: 1%{dist}
URL:     https://github.com/winft/como
Source:  https://github.com/winft/como/archive/refs/tags/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
License: GPLv2
Summary: Library collection to easily create Wayland and X11 compositors

BuildRequires: cmake
%if %{with gcc}
BuildRequires: gcc-toolset-14-gcc gcc-toolset-14-gcc-c++
%else
BuildRequires: clang
%endif
BuildRequires: extra-cmake-modules >= 6.0
BuildRequires: libepoxy-devel
BuildRequires: pixman-devel
BuildRequires: wrapland-devel >= 0.600
BuildRequires: wlroots-devel >= 0.17
BuildRequires: freetype-devel
BuildRequires: fontconfig-devel
BuildRequires: cmake
BuildRequires: cmake(Qt6DBus) >= 6.6
BuildRequires: cmake(Qt6Quick)
BuildRequires: cmake(Qt6QuickControls2)
BuildRequires: cmake(Qt6UiTools)
BuildRequires: cmake(Qt6Concurrent)
BuildRequires: cmake(Qt6Core5Compat)
BuildRequires: cmake(KF6DocTools) >= 6.0
BuildRequires: cmake(KF6Kirigami)
BuildRequires: cmake(KScreenLocker) >= 6.0
BuildRequires: cmake(Plasma) >= 6.0
BuildRequires: cmake(KDecoration2)
BuildRequires: cmake(Breeze) >= 6.0
BuildRequires: cmake(QAccessibilityClient6)
BuildRequires: pkgconfig
BuildRequires: pkgconfig(xorg-server)
BuildRequires: pkgconfig(wayland-egl)
BuildRequires: pkgconfig(xkbcommon)
BuildRequires: pkgconfig(libinput) >= 1.9
BuildRequires: pkgconfig(xwayland)
BuildRequires: pkgconfig(libpcap)

Requires: rx-libinput
Requires: rx-libwayland-egl


%description
The Compositor Modules (COMO) are a robust and versatile set of libraries
to create compositors for the Wayland and X11 windowing systems on Linux.

%package devel
Summary:  Devel files for como
Requires: %{name} = %{version}-%{release}

%description devel
%{summary}.

%prep
%autosetup -p1

%build
%if %{with gcc}
%enable_devtoolset14
export CC=gcc
export CXX=c++
%endif

export PKG_CONFIG_PATH=%{_rxlibdir}/pkgconfig${PKG_CONFIG_PATH:+:${PKG_CONFIG_PATH}}
export LDFLAGS="-L%{_rxlibdir} -Wl,-rpath=%{_rxlibdir} ${LDFLAGS:-%__global_ldflags}"
%cmake_kf6

%cmake_build

%install
%cmake_install

# Fix for wrong include paths
for i in como-targets como-targets-release
do
  sed -i 's@${_IMPORT_PREFIX}//usr@${_IMPORT_PREFIX}@g' %{buildroot}%{_libdir}/cmake/como/$i.cmake
done

%files
%license LICENSE
%doc README.md
%{_libexecdir}/como_killer_helper
%{_libdir}/libbase-x11-backend.so
%{_libdir}/libcomo-*.so.*
%{_libdir}/kconf_update_bin/*
%{_qt6_plugindir}/*
%{_qt6_qmldir}/*
%{_userunitdir}/plasma-kwin_*.service
%{_datadir}/como/*
%{_datadir}/config.kcfg/*
%{_datadir}/dbus-1/interfaces/*.xml
%{_docdir}/HTML
%{_datadir}/icons/hicolor/*/apps/kwin.*
%{_datadir}/kconf_update/kwin.upd
%{_datadir}/knotifications6/kwin.notifyrc
%{_datadir}/knsrcfiles/aurorae.knsrc
%{_datadir}/kwin/aurorae/*.qml
%{_datadir}/kwin/builtin-effects/*.json
%{_datadir}/kwin/*.png
%{_datadir}/kwin/decorations/*
%{_datadir}/kwin/effects/*
%{_datadir}/kwin/scripts/*
%{_datadir}/kwin/tabbox/*
%{_datadir}/qlogging-categories6/org_kde_kwin.categories

%files devel
%{_libdir}/cmake/KWinDBusInterface/*.cmake
%{_libdir}/cmake/como/*
%{_includedir}/como/*
%{_includedir}/como_version.h
