File prismlauncher.spec of Package prismlauncher

%define real_name prismlauncher
%define nice_name PrismLauncher
%bcond_without qt6

# Change this variables if you want to use custom keys
# Leave blank if you want to build Prism Launcher without MSA id or curseforge api key
%define msa_id default
%define curseforge_key default

%if %{with qt6}
%define qt_version 6
%define min_qt_version 6
%else
%define qt_version 5
%define min_qt_version 5.12
%endif

%define build_platform openSUSE


%if %{with qt6}
Name:             prismlauncher
%else
Name:             prismlauncher-qt5
%endif
Version:          @SERVICE@
Release:          1%{?dist}
Summary:          Minecraft launcher with ability to manage multiple instances
License:          GPL-3.0-only
Group:            Amusements/Games/Action/Other
URL:              https://prismlauncher.org/
Source0:          _service
Patch0:           0001-find-cmark-with-pkgconfig.patch

BuildRequires:    cmake >= 3.15
BuildRequires:    extra-cmake-modules
%if 0%{?suse_version} >= 1600
BuildRequires:    gcc-c++
%else
BuildRequires:    gcc9
BuildRequires:    gcc9-c++
%endif
BuildRequires:    java-17-openjdk-devel
BuildRequires:    update-desktop-files
BuildRequires:    appstream-glib
BuildRequires:    cmake(Qt%{qt_version}Concurrent) >= %{min_qt_version}
BuildRequires:    cmake(Qt%{qt_version}Core) >= %{min_qt_version}
BuildRequires:    cmake(Qt%{qt_version}Gui) >= %{min_qt_version}
BuildRequires:    cmake(Qt%{qt_version}Network) >= %{min_qt_version}
BuildRequires:    cmake(Qt%{qt_version}Test) >= %{min_qt_version}
BuildRequires:    cmake(Qt%{qt_version}Widgets) >= %{min_qt_version}
BuildRequires:    cmake(Qt%{qt_version}Xml) >= %{min_qt_version}

%if %{with qt6}
BuildRequires:    cmake(Qt6Core5Compat)
%endif

BuildRequires:    pkgconfig(bzip2)
# i guess this hasn't been backported to leap
# https://build.opensuse.org/request/show/934673
%if 0%{?suse_version} <= 1500
BuildRequires:    cmark
%endif
BuildRequires:    pkgconfig(libcmark)
BuildRequires:    pkgconfig(scdoc)
BuildRequires:    pkgconfig(zlib)

%if 0%{?suse_version} >= 1550
BuildRequires:    cmake(QuaZip-Qt%{qt_version})
%endif

Requires:         %{!?with_qt6:lib}qt%{qt_version}-%{!?with_qt6:qt}imageformats
Requires:         libQt%{qt_version}Svg%{qt_version}
Requires:         javapackages-filesystem
# Make Java Recommends in case user has non-RPM java installations
Recommends:       java-21
Recommends:       java-17
Recommends:       java-1.8.0

# xrandr needed for LWJGL [2.9.2, 3) https://github.com/LWJGL/lwjgl/issues/128
Recommends:       xrandr
# Prism supports enabling gamemode
%if 0%{?suse_version} > 1500
Suggests:         gamemode
%endif

%if %{without qt6}
Conflicts:        %{real_name}
%endif


%description
A custom launcher for Minecraft that allows you to easily manage
multiple installations of Minecraft at once (Fork of MultiMC)


%prep
%setup -q -n %{_sourcedir}/%{real_name}-%{version} -T -D
%autopatch -p1

# Do not set RPATH
sed -i "s|\$ORIGIN/||" CMakeLists.txt


%build
%cmake \
  %if 0%{?suse_version} < 1600
  -DCMAKE_C_COMPILER="gcc-9" \
  -DCMAKE_CXX_COMPILER="g++-9" \
  %endif
  -DLauncher_QT_VERSION_MAJOR="%{qt_version}" \
  -DLauncher_BUILD_PLATFORM="%{build_platform}" \
  %if "%{msa_id}" != "default"
  -DLauncher_MSA_CLIENT_ID="%{msa_id}" \
  %endif
  %if "%{curseforge_key}" != "default"
  -DLauncher_CURSEFORGE_API_KEY="%{curseforge_key}" \
  %endif
  -DBUILD_TESTING=OFF

%cmake_build


%install
%cmake_install
%suse_update_desktop_file org.prismlauncher.PrismLauncher


%check
%ctest

%if 0%{?suse_version} > 1500
appstream-util validate-relax --nonet \
    %{buildroot}%{_datadir}/metainfo/org.prismlauncher.PrismLauncher.metainfo.xml
%endif


%files
# TODO: find out why these aren't found on tumbleweed
# %doc README.md
# %license LICENSE COPYING.md
%dir %{_datadir}/%{nice_name}
%dir %{_datadir}/qlogging-categories%{qt_version}
%{_bindir}/%{real_name}
%{_datadir}/%{nice_name}/NewLaunch.jar
%{_datadir}/%{nice_name}/NewLaunchLegacy.jar
%{_datadir}/%{nice_name}/JavaCheck.jar
%{_datadir}/%{nice_name}/qtlogging.ini
%{_datadir}/applications/org.prismlauncher.PrismLauncher.desktop
%{_datadir}/icons/hicolor/scalable/apps/org.prismlauncher.PrismLauncher.svg
%{_datadir}/metainfo/org.prismlauncher.PrismLauncher.metainfo.xml
%{_datadir}/mime/packages/modrinth-mrpack-mime.xml
%{_datadir}/qlogging-categories%{qt_version}/prismlauncher.categories
%{_mandir}/man?/prismlauncher.*


%changelog
openSUSE Build Service is sponsored by