File cloudcompare.spec of Package cloudcompare

#
# spec file for package cloudcompare
#
# Copyright (c) 2020 SUSE LLC
# Copyright (c) 2020 Ioda-Net Sàrl, Charmoille, Switzerland. Bruno Friedmann
# Copyright (c) 2017 Miro Hrončok and possibly others
#
# 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/
#

# Not build, Requires a propietary library
#  -DPLUGIN_IO_QFBX=OFF \ 
#  -DPLUGIN_IO_QRDB=OFF \

# TODO:
#  -DPLUGIN_STANDARD_QCORK=OFF \  //Only Win?, Cork + MPIR  https://github.com/cloudcompare/cork
#  -DPLUGIN_STANDARD_QPCL=OFF \  //requires external PCL  https://github.com/PointCloudLibrary/pcl/wiki
#   investigate COMPILE_CC_CORE_LIB_WITH_TBB


%global cname   CloudCompare
# Do not RPM provide .so files only used internally:
%global __provides_exclude_from ^%{_libdir}/%{name}/.*$
%global __requires_exclude ^lib(Q)?CC_.*$
Name:           cloudcompare
Version:        2.11.3
Release:        0
Summary:        3D point cloud and mesh processing software
# Main part is GPLv2+
# CCLib is LGPLv2+
# Plugins from Source1 and Source2 are MIT
# dxflib is GPLv2+
# shapelib is (LGPLv2+ or MIT)
# as the result is compiled into one piece, it should be:
License:        GPL-2.0-or-later
Group:          Productivity/Graphics/3D Editors
URL:            https://www.cloudcompare.org/
Source0:        https://github.com/%{cname}/%{cname}/archive/v%{version}/%{cname}-%{version}.tar.gz
Source2:        dlib-19.21.tar.xz
Source3:        PoissonRecon-8683f6c.tar.xz
# desktop files
Source4:        %{name}.desktop
Source5:        ccviewer.desktop
# PATCH: Add color to export points & save as dxf 2000
Patch1:         cc_dxf-color.patch
Patch2:         cc_pdal_230.patch
Patch3:         cc_e57-includes.patch
Patch4:         CC-c14.patch
Patch5:         CC-qPCL-build.patch
Patch6:         cc_externalE57.patch
#needed by leap 15.2
Patch7:         cc_constexpr.patch
BuildRequires:  PDAL-devel
BuildRequires:  cgal-devel
BuildRequires:  cmake >= 3
BuildRequires:  desktop-file-utils
BuildRequires:  fdupes
BuildRequires:  ffmpeg-devel
BuildRequires:  libavcodec-devel
BuildRequires:  libavutil-devel
BuildRequires:  libavformat-devel
BuildRequires:  libswscale-devel
%if 0%{?is_opensuse}
%if 0%{?sle_version} == 150200 || 0%{?sle_version} == 150300
BuildRequires:  gcc10-c++ >= 10
%else
BuildRequires:  gcc-c++
%endif
%endif
BuildRequires:  laszip-devel
BuildRequires:  libboost_atomic-devel
BuildRequires:  libboost_filesystem-devel
BuildRequires:  libboost_headers-devel
BuildRequires:  libboost_program_options-devel
BuildRequires:  libboost_system-devel
BuildRequires:  libboost_thread-devel
BuildRequires:  libgomp1
BuildRequires:  tbb-devel
BuildRequires:  pkgconfig
BuildRequires:  pkgconfig(Qt5Concurrent)
BuildRequires:  pkgconfig(Qt5Core)
BuildRequires:  pkgconfig(Qt5OpenGL)
BuildRequires:  pkgconfig(Qt5OpenGLExtensions)
BuildRequires:  pkgconfig(Qt5PrintSupport)
BuildRequires:  pkgconfig(Qt5Svg)
BuildRequires:  pkgconfig(Qt5Test)
BuildRequires:  pkgconfig(Qt5UiTools)
BuildRequires:  pkgconfig(cunit)
BuildRequires:  pkgconfig(eigen3)
BuildRequires:  pkgconfig(gdal) > 3.0
BuildRequires:  pkgconfig(gl)
BuildRequires:  pkgconfig(glew)
BuildRequires:  pkgconfig(glu)
BuildRequires:  pkgconfig(xerces-c)
BuildRequires:  pkgconfig(zlib)
BuildRequires:  libcork-devel
BuildRequires:  libE57Format-devel
#For PCL plugin
BuildRequires:  libpcl-devel
BuildRequires:  libboost_iostreams-devel
BuildRequires:  vtk-devel
BuildRequires:  qhull_r-devel
BuildRequires:  libusb-1_0-devel
BuildRequires:  libpcap-devel
BuildRequires:  eigen3-devel
Requires:       hicolor-icon-theme >= 0
Provides:       bundled(dxflib) = 3.17.0
Provides:       bundled(shapelib) = 1.5.0
Provides:       %{cname} = %{version}-%{release}
%{?_isa:Provides:       %{cname}%{_isa} = %{version}-%{release}}

%description
CloudCompare is a 3D point cloud (and triangular mesh) processing software.
It has been originally designed to perform comparison between two 3D points
clouds (such as the ones obtained with a laser scanner) or between a point
cloud and a triangular mesh.
It relies on a specific octree structure that enables great performances in
this particular function. It was also meant to deal with huge point clouds
(typically more than 10 millions points, and up to 120 millions with 2 Gb of
memory).

Afterwards, it has been extended to a more generic point cloud processing
software, including many advanced algorithms (registration, resampling,
color/normal/scalar fields handling, statistics computation, sensor
management, interactive or automatic segmentation, display enhancement...).

%package doc
Summary:        Documentation for %{cname}
Requires:       %{name} = %{version}-%{release}
BuildArch:      noarch

%description doc
CloudCompare is a 3D point cloud (and triangular mesh) processing software.
This is the documentation.

%prep
%setup -q -n %{cname}-%{version}
# On 64bits, change /usr/lib/cloudcompare to /usr/lib64/cloudcompare
# Actually
sed -i 's,lib/%{name},%{_lib}/%{name},g' $(grep -r lib/%{name} -l)
mkdir plugins/core/Standard/qCanupo/dlib
cd plugins/core/Standard/qCanupo/dlib
xz -dc %{SOURCE2} | tar --strip-components=1 -xof -
cd %{_builddir}/%{cname}-%{version}
cd plugins/core/Standard/qPoissonRecon/PoissonReconLib
xz -dc %{SOURCE3} | tar --strip-components=1 -xof -
cd %{_builddir}/%{cname}-%{version}
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%if 0%{?sle_version} == 150200 && 0%{?is_opensuse}
%patch7 -p1
%endif

# Remove french TeX docs
rm -rf doc/fr*


%build
export LDFLAGS="-Wl,-z,relro,-z,now -pie"
export CFLAGS="%{optflags} -fPIE -pie -fno-strict-aliasing"
export CXXFLAGS="%{optflags} -fPIE -pie -fno-strict-aliasing -std=c++14 -DSUPPORT_TOPO_STREAM_OPERATORS"
export OpenGL_GL_PREFERENCE="GLVND"
%if 0%{?is_opensuse}
%if 0%{?sle_version} == 150200 || 0%{?sle_version} == 150300
export CMAKE_C_COMPILER="/usr/bin/g++-10"
export CMAKE_CXX_COMPILER="/usr/bin/g++-10"
%endif
%endif
%cmake \
  -DCMAKE_BUILD_TYPE=Release \
  -DEIGEN_ROOT_DIR=%{_includedir}/eigen3 \
  -DEIGEN_INCLUDE_DIR=%{_includedir}/eigen3 \
  -DEIGEN_ROOT=%{_includedir}/eigen3 \
%if 0%{?is_opensuse}
%if 0%{?sle_version} == 150200 || 0%{?sle_version} == 150300
  -DCMAKE_C_COMPILER=/usr/bin/gcc-10 \
  -DCMAKE_CXX_COMPILER=/usr/bin/g++-10 \
%endif
%endif
  -DJSON_ROOT_DIR=%{_includedir}/jsoncpp \
  -DFFMPEG_INCLUDE_DIR=%{_includedir}/ffmpeg \
  -DFFMPEG_LIBRARY_DIR=%{_libdir} \
  -DDLIB_ROOT=%{_builddir}/%{cname}-%{version}/plugins/core/Standard/qCanupo/dlib \
  -DCORK_INCLUDE_DIR=%{_includedir}/cork \
  -DCORK_RELEASE_LIBRARY_FILE=%{_libdir}/libcork.a \
  -DMPIR_INCLUDE_DIR=%{_includedir} \
  -DMPIR_RELEASE_LIBRARY_FILE=%{_libdir}/libmpir.so \
  -DOPTION_SCALAR_DOUBLE=ON \
  -DCOMPILE_CC_CORE_LIB_WITH_QT=ON \
  -DCOMPILE_CC_CORE_LIB_WITH_CGAL=ON \
  -DCOMPILE_CC_CORE_LIB_WITH_TBB=ON \
  -DOpenGL_GL_PREFERENCE=GLVND \
  -DOPTION_USE_GDAL= ON \
  -DOPTION_USE_SHAPE_LIB=ON \
  -DOPTION_USE_DXF_LIB=ON \
  -DOPTION_BUILD_CCVIEWER=ON \
  -DPLUGIN_EXAMPLE_GL=ON \
  -DPLUGIN_EXAMPLE_IO=ON \
  -DPLUGIN_EXAMPLE_STANDARD=ON \
  -DPLUGIN_GL_QEDL=ON \
  -DPLUGIN_GL_QSSAO=ON \
  -DPLUGIN_IO_QADDITIONAL=ON \
  -DPLUGIN_IO_QCORE=ON \
  -DPLUGIN_IO_QCSV_MATRIX=ON \
  -DPLUGIN_IO_QE57=ON \
  -DE57Format_INCLUDE_DIRS=%{_includedir}/E57Format \
  -DE57Format_LIBRARIES=%{_libdir}/libE57Format.so \
  -DPLUGIN_IO_QPDAL=ON \
  -DPLUGIN_IO_QPHOTOSCAN=ON  \
  -DPLUGIN_IO_QRDB=OFF \
  -DPLUGIN_STANDARD_QANIMATION=ON \
  -DWITH_FFMPEG_SUPPORT=ON \
  -DPLUGIN_STANDARD_QBROOM=ON \
  -DPLUGIN_STANDARD_QCANUPO=ON \
  -DPLUGIN_STANDARD_QCOMPASS=ON \
  -DPLUGIN_STANDARD_QCORK=ON \
  -DPLUGIN_STANDARD_QCSF=ON \
  -DPLUGIN_STANDARD_QFACETS=ON \
  -DPLUGIN_STANDARD_QHOUGH_NORMALS=ON \
  -DPLUGIN_STANDARD_QHPR=ON \
  -DPLUGIN_STANDARD_QM3C2=ON \
  -DPLUGIN_STANDARD_QPCL=ON \
  -DPCL_INCLUDE_DIRS=%{_includedir}/pcl-1.12 \
  -DPCL_LIBRARY_DIRS=%{_libdir} \
  -DPCL_DIR=%{_includedir}/pcl-1.12 \
  -DPCL_LIBRARIES=%{_libdir}/libpcl_recognition.so \
  -DQHULL_LIBRARIES=%{_libdir} \
  -DQHULL_INCLUDE_DIRS=%{_includedir} \
  -DPCL_COMMON_LIBRARY=%{_libdir}/libpcl_common.so \
  -DPCL_KDTREE_LIBRARY=%{_libdir}/libpcl_kdtree.so \
  -DPCL_OCTREE_LIBRARY=%{_libdir}/libpcl_octree.so \
  -DPCL_SEARCH_LIBRARY=%{_libdir}/libpcl_search.so \
  -DPCL_SAMPLE_CONSENSUS_LIBRARY=%{_libdir}/libpcl_sample_consensus.so \
  -DPCL_FILTERS_LIBRARY=%{_libdir}/libpcl_filters.so \
  -DPCL_IO_LIBRARY=%{_libdir}/libpcl_io.so \
  -DPCL_FEATURES_LIBRARY=%{_libdir}/libpcl_features.so \
  -DPCL_ML_LIBRARY=%{_libdir}/libpcl_ml.so \
  -DPCL_SEGMENTATION_LIBRARY=%{_libdir}/libpcl_segmentation.so \
  -DPCL_VISUALIZATION_LIBRARY=%{_libdir}/libpcl_visualization.so \
  -DPCL_KEYPOINTS_LIBRARY=%{_libdir}/libpcl_keypoints.so \
  -DPCL_SURFACE_LIBRARY=%{_libdir}/libpcl_surface.so \
  -DPCL_REGISTRATION_LIBRARY=%{_libdir}/libpcl_registration.so \
  -DPCL_TRACKING_LIBRARY=%{_libdir}/libpcl_tracking.so \
  -DPCL_RECOGNITION_LIBRARY=%{_libdir}/libpcl_recognition.so \
  -DPCL_STEREO_LIBRARY=%{_libdir}/libpcl_stereo.so \
  -DPCL_OUTOFCORE_LIBRARY=%{_libdir}/libpcl_outofcore.so \
  -DPCL_PEOPLE_LIBRARY=%{_libdir}/libpcl_people.so \
  -DPLUGIN_STANDARD_QPCV=ON \
  -DPLUGIN_STANDARD_QPOISSON_RECON=ON \
%ifarch %ix86 x86_64
  -DPLUGIN_STANDARD_QRANSAC_SD=ON \
%else
  -DPLUGIN_STANDARD_QRANSAC_SD=OFF \
%endif
  -DPLUGIN_STANDARD_QSRA=ON \
  -DBUILD_TESTING=ON \
  ..


%make_build VERBOSE=1

%install
%cmake_install VERBOSE=1
chmod 0755 %{buildroot}%{_bindir}/%{cname}
chmod 0755 %{buildroot}%{_bindir}/ccViewer

# lower-case symblinks
ln -s ./%{cname} %{buildroot}%{_bindir}/%{name}
ln -s ./ccViewer %{buildroot}%{_bindir}/ccviewer

# icons
for RES in 16 32 64 256; do
  mkdir -p %{buildroot}%{_datadir}/icons/hicolor/${RES}x${RES}/apps/
  cp qCC/images/icon/cc_icon_${RES}.png %{buildroot}%{_datadir}/icons/hicolor/${RES}x${RES}/apps/%{name}.png
  cp qCC/images/icon/cc_viewer_icon_${RES}.png %{buildroot}%{_datadir}/icons/hicolor/${RES}x${RES}/apps/ccviewer.png
done

# desktop files
desktop-file-install --dir=%{buildroot}%{_datadir}/applications %{SOURCE4}
desktop-file-install --dir=%{buildroot}%{_datadir}/applications %{SOURCE5}
%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig


%files
%doc README.md CONTRIBUTING.md CHANGELOG.md
%license license.txt doc/license_headers.txt
%{_bindir}/%{name}
%{_bindir}/%{cname}
%{_bindir}/ccviewer
%{_bindir}/ccViewer
%{_libdir}/%{name}/
%{_datadir}/%{name}/
%exclude %{_datadir}/%{name}/CHANGELOG.md
%exclude %{_datadir}/%{name}/license.txt
%dir %{_datadir}/icons/hicolor
%dir %{_datadir}/icons/hicolor/16x16
%dir %{_datadir}/icons/hicolor/16x16/apps
%dir %{_datadir}/icons/hicolor/32x32
%dir %{_datadir}/icons/hicolor/32x32/apps
%dir %{_datadir}/icons/hicolor/64x64
%dir %{_datadir}/icons/hicolor/64x64/apps
%dir %{_datadir}/icons/hicolor/256x256
%dir %{_datadir}/icons/hicolor/256x256/apps
%{_datadir}/icons/hicolor/*/apps/*.png
%{_datadir}/applications/*.desktop

%files doc
%doc doc

%changelog
openSUSE Build Service is sponsored by