File orca-slicer.spec of Package orca-slicer

Name:           orca-slicer
Version:        2.2.0
Release:        1%{?dist}
Summary:        G-code generator for 3D printers
License:        AGPL-3.0-only
URL:            https://github.com/SoftFever/OrcaSlicer
Source0:        %{url}/archive/v%{version}/OrcaSlicer-%{version}.tar.gz
Source5:        https://github.com/tamasmeszaros/openvdb/archive/a68fd58d0e2b85f01adeb8b13d7555183ab10aa5.tar.gz#/openvdb-8.2.tar.gz
Patch0:         orca-slicer-ambiguous-min.patch
Patch1:         orca-slicer-ambiguous-set_values.patch
Patch2:         orca-slicer-unbundle-boost-nowide.patch
Patch3:         orca-slicer-unbundle-opencv.patch
Patch4:         orca-slicer-newer-opencascade.patch
Patch5:         orca-slicer-fix-asserts-wxwidgets.patch
Patch6:         orca-slicer-link-webkit2gtk.patch
Patch7:         orca-slicer-tbb-spin_mutex.patch
Patch8:         orca-slicer-fix-broken-assertions.patch
BuildRequires:  cmake
BuildRequires:  dbus-devel
BuildRequires:  eglexternalplatform-devel
BuildRequires:  extra-cmake-modules
BuildRequires:  file
BuildRequires:  gcc
BuildRequires:  gcc-c++
BuildRequires:  gettext
BuildRequires:  git
BuildRequires:  gstreamer1-devel
BuildRequires:  gstreamermm-devel
BuildRequires:  gtk3-devel
BuildRequires:  libmspack-devel
BuildRequires:  libsecret-devel
BuildRequires:  libtool
BuildRequires:  m4
BuildRequires:  mesa-libGLU-devel
BuildRequires:  mesa-libOSMesa-devel
BuildRequires:  ninja-build
BuildRequires:  openssl-devel
BuildRequires:  perl-FindBin
BuildRequires:  texinfo
BuildRequires:  wayland-protocols-devel
BuildRequires:  webkit2gtk4.1-devel
BuildRequires:  wget
BuildRequires:  libcurl-devel
BuildRequires:  zlib-ng-devel
BuildRequires:  libpng-devel
BuildRequires:  expat-devel
BuildRequires:  libjpeg-turbo-devel
BuildRequires:  libtiff-devel
BuildRequires:  freetype-devel
BuildRequires:  openssl-devel
BuildRequires:  opencv-devel
BuildRequires:  opencascade-devel
BuildRequires:  wxGTK-devel
BuildRequires:  boost-devel
BuildRequires:  cereal-devel
BuildRequires:  qhull-devel
BuildRequires:  glew-devel
BuildRequires:  glfw-devel
BuildRequires:  opencsg-devel
BuildRequires:  tbb-devel
BuildRequires:  blosc-devel
BuildRequires:  openexr2-devel
BuildRequires:  gmp-devel
BuildRequires:  mpfr-devel
BuildRequires:  CGAL-devel
BuildRequires:  NLopt-devel

# License: MPL 2.0
# Upstream: https://github.com/tamasmeszaros/openvdb
Provides: bundled(openvdb) = 8.2.0

# In case someone tries to install the upstream name
Provides: OrcaSlicer = %{?epoch:%{epoch}:}%{version}-%{release}


%description
Orca Slicer is an open source slicer for FDM printers.

Main features:
* Auto-calibration for all printers;
* Sandwich (inner-outer-inner) mode -
  An improved version of the External Perimeters First mode;
* Precise wall;
* Polyholes conversion support: SuperSlicer Wiki: Polyholes;
* Klipper support;
* More granular controls.


%prep
%autosetup -p1 -n OrcaSlicer-%{version}

# Ugly workaround for a bug with CGAL adding "-isystem /usr/include"
# in the middle of g++ command line options, causing /usr/include to move
# to the middle of include files search path and breaking #include_next
# for math.h and stdlib.h in <cmath> and <cstdlib> C++ headers respectively.
mkdir include
ln -s %{_includedir}/math.h %{_includedir}/stdlib.h include

(cd src && tar xvzf %{SOURCE5} && mv openvdb-* openvdb)

sed -i \
    -e '/DEPENDS /d' \
    -e 's#URL https.*#SOURCE_DIR ../../../src/openvdb#' \
    -e 's/-DUSE_BLOSC=ON/-DUSE_BLOSC=OFF/' \
    -e "/CMAKE_ARGS/a        \"-DCMAKE_CXX_FLAGS=%{?build_cxxflags}\"" \
    deps/OpenVDB/OpenVDB.cmake


%build
mkdir -p deps/build/release
%{set_build_flags}
cmake -S deps -B deps/build/release -DDESTDIR="${PWD}/deps/build/destdir"
cmake --build deps/build/release -v --target dep_OpenVDB

%cmake \
       -DCMAKE_BUILD_TYPE=Release \
       -DCMAKE_PREFIX_PATH="${PWD}/deps/build/destdir/usr/local" \
       -DCMAKE_CXX_FLAGS="$CXXFLAGS -Wno-error=template-id-cdtor -idirafter $PWD/include -DBOOST_LOG_DYN_LINK" \
       -DSLIC3R_FHS=ON \
       -DSLIC3R_PCH=OFF \
       -DORCA_TOOLS=ON \
       -DOPENVDB_USE_STATIC_LIBS=ON \
       -DSLIC3R_GTK=3
%cmake_build


%install
%cmake_install

rm %{buildroot}%{_prefix}/LICENSE.txt


%files
%license LICENSE.txt
%doc README.md SECURITY.md
%{_bindir}/%{name}
%{_datadir}/icons/hicolor/*/apps/OrcaSlicer*.png
%{_datadir}/applications/OrcaSlicer.desktop
%{_datadir}/OrcaSlicer