File SuperSlicer.spec of Package SuperSlicer

#
# spec file for package SuperSlicer
#
# Copyright (c) 2023 SUSE LLC
#
# 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 https://bugs.opensuse.org/
#


%define __builder ninja
Name:           SuperSlicer
Version:        2.5.60.0+6155.g7237ad0b
Release:        0
Summary:        G-code generator for 3D printers (RepRap, Makerbot, Ultimaker etc.)
License:        AGPL-3.0-only
Group:          Hardware/Printing
URL:            https://github.com/supermerill/SuperSlicer
Source0:        SuperSlicer-%{version}.tar.xz
Patch0:         0001-Fix-libexpat-build-config.patch
Patch1:         0002-Fix-wxString-bool-type-mismatch.patch
Patch2:         0003-Fix-physical-printer-dialog-build.patch
Patch3:         0004-Fix-OCCT.patch
Patch4:         0005-Fix-Boost-compat.patch
Patch5:         0006-Fix-OctoPrint-string-type-mismatch.patch
Patch6:         0007-Increase-Arachne-resolution.patch
BuildRequires:  blosc-devel
BuildRequires:  cereal-devel
BuildRequires:  cgal-devel
BuildRequires:  cmake
BuildRequires:  dbus-1-devel
BuildRequires:  eigen3-devel >= 3
BuildRequires:  expat
BuildRequires:  fdupes
BuildRequires:  gcc-c++
BuildRequires:  glew-devel
BuildRequires:  gtest >= 1.7
BuildRequires:  hicolor-icon-theme
BuildRequires:  ilmbase-devel
BuildRequires:  libboost_atomic-devel
BuildRequires:  libboost_filesystem-devel
BuildRequires:  libboost_iostreams-devel
BuildRequires:  libboost_locale-devel
BuildRequires:  libboost_log-devel
BuildRequires:  libboost_regex-devel
BuildRequires:  libboost_system-devel
BuildRequires:  libboost_thread-devel
BuildRequires:  libcurl-devel
BuildRequires:  libexpat-devel
BuildRequires:  libudev-devel nanosvg-devel >= 2022.12.22
BuildRequires:  memory-constraints
BuildRequires:  ninja
BuildRequires:  nlopt-devel
BuildRequires:  openvdb-devel >= 7.1
BuildRequires:  tbb-devel qhull_r-devel libbgcode-devel qhullcpp-devel-static
BuildRequires:  update-desktop-files
BuildRequires:  wxGTK3-devel >= 3.2
BuildRequires:  zlib-devel-static
BuildRequires:  cmake(OpenCASCADE)
BuildRequires:  pkgconfig(wayland-client)
BuildRequires:  pkgconfig(wayland-egl)

%description
SuperSlicer takes 3D models (STL, OBJ, AMF) and converts them into G-code
instructions for FFF printers or PNG layers for mSLA 3D printers. It's
compatible with any modern printer based on the RepRap toolchain, including
all those based on the Marlin, Prusa, Sprinter and Repetier firmware.
It also works with Mach3, LinuxCNC and Machinekit controllers.

%prep
%autosetup -p1 -n %{name}-%{version}
%if 0%{?suse_version}
sed -i 's/UNKNOWN/%{release}-%{?is_opensuse:open}SUSE-0%{?suse_version}/' version.inc
%endif
rm resources/udev/90-3dconnexion.rules
sed -i s/scintilla// src/CMakeLists.txt
sed -i "s|find_package(Qhull 7.2 REQUIRED)|find_package(Qhull 8.0.2 REQUIRED)|" src/CMakeLists.txt
sed -i 's#INTERFACE Qhull::qhullcpp#INTERFACE -lqhullcpp#' src/CMakeLists.txt


%build
%limit_build -m 4096
# sse2 flags: see upstream github issue#3781
%cmake -Wno-dev -DSLIC3R_FHS=1 \
       -DSLIC3R_BUILD_TESTS=0 \
       -DSLIC3R_GTK=3 \
       -DOPENVDB_FIND_MODULE_PATH=%{_libdir}/cmake/OpenVDB \
%ifarch i686 i586 i386
       -DCMAKE_C_FLAGS:STRING="%{optflags} -mfpmath=sse -msse2" \
       -DCMAKE_CXX_FLAGS:STRING="%{optflags}  -mfpmath=sse -msse2"
%endif

%cmake_build
%cmake_build gettext_po_to_mo

%install
%cmake_install

%if 0%{?suse_version} > 1500
    %suse_update_desktop_file -i %{name}
    %suse_update_desktop_file -i %{name}-Gcodeviewer
%else
    # Non Tumbleweed versions do not like the chosen categories
    %suse_update_desktop_file -i -r %{name} Graphics 3DGraphics
    %suse_update_desktop_file -i -r %{name}-Gcodeviewer Graphics 3DGraphics
%endif

rm -rf %{buildroot}%{_prefix}/lib/cmake/Angelscript
rm -rf %{buildroot}%{_includedir}
rm -rf %{buildroot}%{_prefix}/lib/libangelscript.a
#
rm -rf %{buildroot}%{_datadir}/%{name}/data
rm -rf %{buildroot}%{_datadir}/%{name}/applications

# Copied and adapted from Fedora package:
# https://src.fedoraproject.org/rpms/prusa-slicer
# Upstream installs the translation source files when they probably shouldn't
rm %{buildroot}%{_datadir}/%{name}/localization/{README.md,list.txt,pom_merger.py,settings.ini,update_all.py}
find %{buildroot}%{_datadir}/%{name}/localization/ -name \*.po -delete
find %{buildroot}%{_datadir}/%{name}/localization/ -name settings.ini -delete

# Copied and adapted from Fedora package:
# https://src.fedoraproject.org/rpms/prusa-slicer
# Handle locale files.  The find_lang macro doesn't work because it doesn't
# understand the directory structure.  This copies part of the funtionality of
# find-lang.sh by:
#   * Getting a listing of all files
#   * removing the buildroot prefix
#   * inserting the proper 'lang' tag
#   * removing everything that doesn't have a lang tag
#   * A list of lang-specific directories is also added
# The resulting file is included in the files list, where we must be careful to
# exclude that directory.
 find %{buildroot}%{_datadir}/%{name}/localization -type f -o -type l | sed '
     s:'"%{buildroot}"'::
     s:\(.*/%{name}/localization/\)\([^/_]\+\)\(.*\.mo$\):%%lang(\2) \1\2\3:
     s:^\([^%].*\)::
     s:%lang(C) ::
     /^$/d
 ' > lang-files
 find %{buildroot}%{_datadir}/%{name}/localization -type d | sed '
     s:'"%{buildroot}"'::
     s:\(.*\):%dir \1:
 ' >> lang-files

%fdupes %{buildroot}%{_datadir}

%files -f lang-files
%{_bindir}/superslicer*
%{_libdir}/OCCTWrapper.*
%dir %{_datadir}/%{name}/
%{_datadir}/%{name}/{fonts,icons,models,profiles,shaders,udev,ui_layout,calibration,splashscreen,shapes}/
%{_datadir}/icons/hicolor/*/apps/%{name}*.png
%{_datadir}/applications/%{name}*.desktop
%license LICENSE
%doc README.md doc/

%changelog
openSUSE Build Service is sponsored by