File openMVG.spec of Package openMVG

#
# spec file for package openMVG
#
# Copyright (c) 2023 SUSE LLC
# Copyright (c) 2018-2019 Malcolm J Lewis <malcolmlewis@opensuse.org>
#
# 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 major   2
%define minor   0
%define libname libopenMVG%{major}
Name:           openMVG
Version:        %{major}.%{minor}
Release:        0
Summary:        Library for Multiple-View-Geometry and Structure-From-Motion
License:        MPL-2.0
URL:            https://github.com/openMVG/openMVG
Source0:        https://github.com/openMVG/openMVG/archive/refs/tags/v%{version}.tar.gz#/openMVG-%{version}.tar.gz
# PATCH-FIX-UPSTREAM
Patch0:         https://github.com/openMVG/openMVG/commit/55f3eec9e5d1732691a94e777b3b3bdfc51db230.patch#/fix_external_cereal.patch
# PATCH-FIX-UPSTREAM
Patch1:         https://github.com/openMVG/openMVG/commit/1f9b938a4afcaf067b331eefeb9fa8743d1dfaba.patch#/fix_build_agains_cereal_1_3_1.patch
# PATCH-FIX-UPSTREAM
Patch2:         https://github.com/openMVG/openMVG/pull/2148.patch#/fix_library_installation.patch
# PATCH-FIX-UPSTREAM https://github.com/openMVG/openMVG/issues/1881#issuecomment-886150459
Patch3:         openmvg-drop-cpuid.patch
# PATCH-FIX-UPSTREAM
Patch4:         https://github.com/openMVG/openMVG/pull/2147.patch#/flann_prefer_cmake_config.patch
# PATCH-FIX-UPSTREAM
Patch5:         https://github.com/openMVG/openMVG/pull/1947/commits/da0448031f0d23790d242b2d440fcbca3f57f7a0.patch#/fix_underlinking.patch
BuildRequires:  blas-devel
BuildRequires:  cereal-devel
BuildRequires:  clang
BuildRequires:  flann-devel
BuildRequires:  fdupes
BuildRequires:  gcc-c++
BuildRequires:  glpk-devel
BuildRequires:  glog-devel
BuildRequires:  lapack-devel
BuildRequires:  lemon-devel
BuildRequires:  pkgconfig
BuildRequires:  cmake(Ceres)
BuildRequires:  pkgconfig(Qt5Core)
BuildRequires:  pkgconfig(Qt5OpenGL)
BuildRequires:  pkgconfig(Qt5Svg)
BuildRequires:  pkgconfig(Qt5Widgets)
BuildRequires:  pkgconfig(cbc)
BuildRequires:  pkgconfig(clp)
BuildRequires:  pkgconfig(osi-cbc)
BuildRequires:  pkgconfig(eigen3)
BuildRequires:  pkgconfig(libjpeg)
BuildRequires:  pkgconfig(libpng16)
BuildRequires:  pkgconfig(libtiff-4)
Recommends:     openMVS

%description
Library for computer-vision scientists and especially targeted to the Multiple
View Geometry community. It is designed to provide an easy access to the
classical problem solvers in Multiple View Geometry and solve them accurately.

%package -n %{libname}
Summary:        Multiple View Geometry library

%description -n %{libname}
Library for computer-vision scientists and especially targeted to the Multiple
View Geometry community. It is designed to provide an easy access to the
classical problem solvers in Multiple View Geometry and solve them accurately.

%package devel
Summary:        Files for developing with Multiple View Geometry library
Requires:       %{name} = %{version}-%{release}

%description devel
Header files and definitions for developing with %{name}.

%prep
%setup -q -n %{name}-%{version}/src
%patch0 -p2
%patch1 -p2
%patch2 -p2
%ifnarch %{ix86} x86_64
# Disable cpuid on non-x86 architectures
%patch3 -p2
%endif
%patch4 -p2
%patch5 -p2

# Remove bundled dependencies available from system
rm -Rf third_party/{lemon,jpeg,png,zlib,cxsparse,ceres-solver,flann,eigen}
# Silence wrong diagnostic
touch dependencies/cereal/include

%build
%cmake -DTARGET_ARCHITECTURE=generic \
       -DOpenMVG_BUILD_DOC:BOOL=OFF \
       -DOpenMVG_BUILD_EXAMPLES:BOOL=ON \
       -DOpenMVG_BUILD_SOFTWARES:BOOL=ON \
       -DOpenMVG_BUILD_GUI_SOFTWARES:BOOL=ON \
       -DOpenMVG_BUILD_SHARED:BOOL=ON \
       -DOpenMVG_BUILD_TESTS:BOOL=ON \
       -DOpenMVG_BUILD_OPENGL_EXAMPLES:BOOL=OFF \
       -DOpenMVG_USE_OPENCV:BOOL=OFF \
       -DOpenMVG_USE_OCVSIFT:BOOL=OFF \
       -DFLANN_INCLUDE_DIR_HINTS:PATH=%{_includedir} \
       -DCOINUTILS_INCLUDE_DIR_HINTS:PATH=%{_includedir} \
       -DCLP_INCLUDE_DIR_HINTS:PATH=%{_includedir} \
       -DOSI_INCLUDE_DIR_HINTS:PATH=%{_includedir} \
       -DLEMON_INCLUDE_DIR_HINTS:PATH=%{_includedir} \
       %{nil}

%cmake_build

%install
%cmake_install

%fdupes %{buildroot}

# Remove static libs
find %{buildroot} -type f -name "*.a" -delete -print

%post -n %{libname} -p /sbin/ldconfig
%postun -n %{libname} -p /sbin/ldconfig

%check
%ifnarch %{ix86}
%ctest
%else
# Accuracy issues with x86 FP
%ctest --exclude-regex openMVG_test_gms_filter
%endif

%files
%{_bindir}/openMVG_main_*
%{_bindir}/ui_openMVG_*
%dir %{_datadir}/%{name}
%{_datadir}/%{name}/sensor_width_camera_database.txt
%{_datadir}/%{name}/webgl

%files -n %{libname}
%license ../LICENSE
%{_libdir}/lib%{name}*.so.%{major}*

%files devel
%doc ../AUTHORS ../CONTRIBUTING.md
%{_includedir}/%{name}_dependencies
%{_includedir}/%{name}
%{_libdir}/lib%{name}*.so
%dir %{_libdir}/%{name}
%dir %{_libdir}/%{name}/cmake
%{_libdir}/%{name}/cmake/*.cmake

%changelog
openSUSE Build Service is sponsored by