File meshlab.spec of Package meshlab

#
# spec file for package meshlab
#
# Copyright (c) 2025 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/
#


%if 0%{?suse_version} >= 1550
%bcond_without gmp
%else
%bcond_with    gmp
%endif

# Optional dependencies not yet used or available
# - embree
# - glTF
# - libe57Format
# - libigl
# - u3d

%define glew_version %(rpm -q --queryformat='%%{version}' glew-devel | sed -nr 's/([0-9.]+).*/\\1/p')

Name:           meshlab
Version:        2025.07
Release:        0
Summary:        System for the processing and editing of unstructured 3D triangular meshes
License:        BSD-3-Clause AND GPL-2.0-or-later
Group:          Productivity/Graphics/3D Editors
URL:            https://www.meshlab.net/
Source0:        https://github.com/cnr-isti-vclab/meshlab/archive/refs/tags/MeshLab-%{version}.tar.gz#/meshlab-MeshLab-%{version}.tar.gz
# Belongs in its own package, but meshlab requires a complete source tree -- https://github.com/cnr-isti-vclab/vcglib/issues/230
Source1:        https://github.com/cnr-isti-vclab/vcglib/archive/refs/tags/%{version}.tar.gz#/vcglib-%{version}.tar.gz
# PATCH-FIX-OPENSUSE -- adjust plugin and shader search path
Patch1:         0001-Use-same-paths-for-shader-plugin-lookup-as-used-for-.patch
# PATCH-FIX-OPENSUSE -- https://github.com/cnr-isti-vclab/vcglib/issues/210
Patch2:         0001-Remove-unused-return-value-in-unused-function.patch
# PATCH-FIX-OPENSUSE
Patch4:         0001-Allow-usage-of-system-provided-levmar.patch

BuildRequires:  cmake
BuildRequires:  desktop-file-utils
BuildRequires:  fdupes
BuildRequires:  gcc-c++
BuildRequires:  hicolor-icon-theme
BuildRequires:  levmar-devel
BuildRequires:  libboost_headers-devel
BuildRequires:  libboost_thread-devel
BuildRequires:  libbz2-devel
BuildRequires:  muparser-devel
BuildRequires:  qhull-devel
BuildRequires:  cmake(CGAL)
BuildRequires:  cmake(Qt5OpenGL)
BuildRequires:  cmake(Qt5Qml)
BuildRequires:  cmake(Qt5Xml)
BuildRequires:  cmake(Qt5XmlPatterns)
BuildRequires:  pkgconfig(eigen3)
BuildRequires:  pkgconfig(gl)
BuildRequires:  pkgconfig(glew)
BuildRequires:  pkgconfig(glu)
BuildRequires:  pkgconfig(xerces-c)
%if %{with gmp}
BuildRequires:  pkgconfig(gmp)
%endif
BuildRequires:  pkgconfig(lib3ds)
# Optional, missing:
#BuildRequires:  pkgconfig(OpenCTM)
# Incompatibility between GLEW and Qt GLES builds
ExcludeArch:    %{arm} aarch64

# Do not add plugins to provides
%global __provides_exclude_from ^%{_libdir}/meshlab/plugins/.*\\.so

%description
MeshLab is an open source, portable, and extensible system for the processing
and editing of unstructured large 3D triangular meshes. The source is
released under the GPL license. The system is aimed to help the processing
of the typical not-so-small unstructured models arising in 3D scanning,
providing a set of tools for editing, cleaning, healing, inspecting,
rendering and converting this kind of meshes.

%prep
%setup -a1 -n %{name}-MeshLab-%{version}

# rename vcglib folder
rmdir src/vcglib
mv vcglib-%{version} src/vcglib

%autopatch -p1

# Remove bundled library sources, since we use the packaged libraries
rm -r src/external/glew*/*

# Change defaults for MESHLAB_ALLOW_DOWNLOAD_*
sed -i '/option/ s|\(MESHLAB_ALLOW_DOWNLOAD.*\) ON|\1 OFF|' src/external/*.cmake
grep -E 'option.*MESHLAB_ALLOW_DOWNLOAD.*' src/external/*.cmake

# set plugin and shader search path
sed -i 's|PLUGIN_DIR|QString("%{_libdir}/meshlab/plugins")|g'  src/common/globals.cpp
sed -i 's|SHADER_DIR|QString("%{_datadir}/meshlab/shaders")|g' src/common/globals.cpp

%build
%cmake \
  -DGLEW_VERSION=%{glew_version} \
  %{nil}
%cmake_build

%install
%cmake_install

for i in 16 48 64 128 512 ; do
  install -D -m 644 src/meshlab/images/eye${i}.png \
                    %{buildroot}%{_datadir}/icons/hicolor/${i}x${i}/apps/meshlab.png
done

# Make sure Xorg or XWayland is used, native Wayland is not working
sed -i -e 's/Exec=.*/Exec=env QT_QPA_PLATFORM=xcb meshlab/' %{buildroot}%{_datadir}/applications/meshlab.desktop
desktop-file-validate %{buildroot}%{_datadir}/applications/meshlab.desktop

install -D -m 0644 -t %{buildroot}%{_mandir}/man1/ docs/man/*.1

%fdupes %{buildroot}%{_datadir}

%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig

%files
%{_bindir}/meshlab
%{_libdir}/meshlab/
%{_datadir}/meshlab/
%{_mandir}/man1/*.1%{?ext_man}
%doc README.md
%doc docs/privacy.txt
%license LICENSE.txt
%license resources/shaders/3Dlabs-license.txt
%license resources/shaders/LightworkDesign-license.txt
%{_datadir}/icons/hicolor/*/apps/meshlab.*
%{_datadir}/applications/meshlab.desktop

%changelog
openSUSE Build Service is sponsored by