File opencv-qt5.spec of Package opencv

#
# spec file for package opencv-qt5
#
# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
#
# 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 http://bugs.opensuse.org/
#


%bcond_without ffmpeg

%define libname lib%{name}
%define soname 6_3

Name:           opencv-qt5
Version:        3.1.0
Release:        0
Summary:        Collection of algorithms for computer vision
License:        BSD-3-Clause
Group:          Development/Libraries/C and C++
Url:            http://opencv.org/
Source0:        https://github.com/Itseez/opencv/archive/%{version}.tar.gz
# This is the FACE module from the opencv_contrib package. Packaged separately to prevent too much usntable modules
Source1:        opencv_contrib_face-3.1.0.tar.bz2
# PATCH-FIX-OPENSUSE opencv-qt5-sobump.diff tittiatcoke@gmail.com -- increase the so version of the libraries to force co-installability with the Qt4 version
Patch0:         opencv-qt5-sobump.diff
# PATCH-FIX-UPSTREAM opencv-gcc5.patch -- support gcc versions without minor version coolo@suse.de
Patch6:         opencv-gcc5.patch
# PATCH-FIX-UPSTREAM opencv-gles.patch -- support Qt5 built with GLES
Patch7:         opencv-gles.patch
# PATCH-FIX-OPENSUSE opencv-build-compare.patch -- avoid republish if some random external version number changes
Patch8:         opencv-build-compare.patch
# PATCH-FIX-OPENSUSE opencv-gcc6-disable-pch.patch -- Disable PCH for GCC6. 
Patch9:         opencv-gcc6-disable-pch.patch
BuildRequires:  cmake
BuildRequires:  fdupes
BuildRequires:  unzip
%if 0%{?suse_version} > 1310
BuildRequires:  gstreamer-plugins-base-devel
%else
BuildRequires:  gstreamer-0_10-plugins-base-devel
BuildRequires:  libucil-devel
BuildRequires:  libunicap-devel
%endif
BuildRequires:  libdc1394-devel
%if 0%{?suse_version} > 1230
BuildRequires:  libeigen3-devel
%else
BuildRequires:  libeigen2-devel
%endif
%if %{with ffmpeg}
BuildRequires:  pkgconfig(libavcodec)
BuildRequires:  pkgconfig(libavformat)
BuildRequires:  pkgconfig(libavutil)
BuildRequires:  pkgconfig(libswscale)
%endif
BuildRequires:  libgphoto2-devel
BuildRequires:  libjasper-devel
BuildRequires:  libjpeg-devel
BuildRequires:  libtiff-devel
BuildRequires:  libv4l-devel
BuildRequires:  pkgconfig(Qt5Concurrent) >= 5.2.0
BuildRequires:  pkgconfig(Qt5Gui) >= 5.2.0
BuildRequires:  pkgconfig(Qt5OpenGL) >= 5.2.0
BuildRequires:  pkgconfig(Qt5Test) >= 5.2.0
BuildRequires:  pkgconfig(Qt5Widgets) >= 5.2.0
%if 0%{?suse_version} > 1220
BuildRequires:  ilmbase-devel
BuildRequires:  openexr-devel
%else
BuildRequires:  OpenEXR-devel
BuildRequires:  libilmbase-devel
%endif
BuildRequires:  libpng16-compat-devel
BuildRequires:  libpng16-devel
BuildRequires:  python-devel
BuildRequires:  python-numpy-devel
BuildRequires:  python3-devel
BuildRequires:  python3-numpy-devel
%if 0%{?suse_version} != 1315 || 0%{?is_opensuse}
BuildRequires:  python-sphinx
%endif
BuildRequires:  zlib-devel
BuildRequires:  pkgconfig(glu)
Conflicts:      opencv
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

%description
OpenCV means IntelĀ® Open Source Computer Vision Library. It is a collection of C
functions and a few C++ classes that implement some popular Image Processing and
Computer Vision algorithms.

%package -n %{libname}%{soname}
Summary:        Development files for using the OpenCV library
Group:          Development/Libraries/C and C++

%description -n %{libname}%{soname}
The Open Computer Vision Library is a collection of algorithms and sample code
for various computer vision problems. The library is compatible with IPL and
utilizes Intel Integrated Performance Primitives for better performance.

%package devel
Summary:        Development files for using the OpenCV library
Group:          Development/Libraries/C and C++
# Since 2.4.7
Provides:       %{name}-devel-static = %{version}
Requires:       %{libname}%{soname} = %{version}
Requires:       %{name} = %{version}
Requires:       pkgconfig(gl)
Requires:       pkgconfig(glu)
Requires:       pkgconfig(ice)
Requires:       pkgconfig(sm)
Requires:       pkgconfig(x11)
Requires:       pkgconfig(xext)
Conflicts:      opencv-devel

%description devel
This package contains the OpenCV C/C++ library and header files, as well as
documentation. It should be installed if you want to develop programs that will
use the OpenCV library.

%package -n python-%{name}
Summary:        Python 2 bindings for apps which use OpenCV
Group:          Development/Libraries/Python
Requires:       python-base >= %{py_ver}
Conflicts:      python-opencv

%description -n python-%{name}
This package contains Python 2 bindings for the OpenCV library.

%package -n python3-%{name}
Summary:        Python 3 bindings for apps which use OpenCV
Group:          Development/Libraries/Python
Requires:       python3-base >= %{py3_ver}
Conflicts:      python3-opencv

%description -n python3-%name
This package contains Python 3 bindings for the OpenCV library.

%package doc
Summary:        Documentation and examples for OpenCV
Group:          Development/Libraries/C and C++
Recommends:     python
# Since this package also contains examples that need -devel to be compiled
Recommends:     %{name}-devel
Conflicts:      opencv-doc

%description doc
This package contains the documentation and examples for the OpenCV library.

%prep
%setup -q -n opencv-%version -a 1
%patch0 -p1
%patch6 -p1
%patch7 -p1
%patch8 -p1
%patch9 -p1

# Remove Windows specific files
rm -f doc/packaging.txt

%build
%ifarch ppc64le
if [ $(gcc -dumpversion) -ge 6 ]; then
export mlra=-mlra
fi
%endif
export CFLAGS="%{optflags} $(getconf LFS_CFLAGS)"
export CXXFLAGS="%{optflags} ${mlra} $(getconf LFS_CFLAGS)"
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release \
      -DCMAKE_INSTALL_PREFIX='%{_prefix}' \
      -DCMAKE_SKIP_RPATH=ON \
      -DBUILD_TESTS=OFF \
      -DINSTALL_C_EXAMPLES=ON \
      -DINSTALL_PYTHON_EXAMPLES=ON \
      -DLIB_SUFFIX=$(echo %{_lib} | cut -b4-) \
      -DENABLE_OMIT_FRAME_POINTER=OFF \
      -DWITH_QT=ON \
      -DWITH_OPENGL=ON \
      -DWITH_UNICAP=ON \
      -DWITH_XINE=ON \
      -DWITH_IPP=OFF \
%if 0%{?suse_version} <= 1310
      -DWITH_GSTREAMER_0_10=ON \
%endif
%ifnarch x86_64
      -DENABLE_SSE=0 \
      -DENABLE_SSE2=0 \
%endif
      -DENABLE_SSE3=0 \
       ..
make %{?_smp_mflags} VERBOSE=1

%install
cd build
make DESTDIR=%{?buildroot:%{buildroot}} install/fast
mkdir -p %{buildroot}%{_docdir}/%{name}-doc
mv %{buildroot}%{_datadir}/OpenCV/samples %{buildroot}%{_docdir}/%{name}-doc/examples

# Fix rpmlint warning "doc-file-dependency"
chmod 644 %{buildroot}%{_docdir}/%{name}-doc/examples/python/*.py

%fdupes -s %{buildroot}%{_docdir}/%{name}-doc/examples
%fdupes -s %{buildroot}%{_includedir}

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

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

%files
%defattr(-,root,root,-)
%{_bindir}/opencv_*
%{_datadir}/OpenCV
%exclude %{_datadir}/OpenCV/OpenCVConfig*.cmake

%files -n %{libname}%{soname}
%defattr(-,root,root,-)
%{_libdir}/lib*.so.*

%files devel
%defattr(-,root,root,-)
%{_includedir}/opencv/
%{_includedir}/opencv2/
%{_libdir}/libopencv_ts.a
%{_libdir}/lib*.so
%{_libdir}/pkgconfig/opencv.pc
%{_datadir}/OpenCV/OpenCVConfig*.cmake

%files -n python-%{name}
%defattr(-,root,root,-)
%{python_sitearch}/cv2.so

%files -n python3-%{name}
%defattr(-,root,root,-)
%{python3_sitearch}/cv2.%{py3_soflags}.so

%files doc
%defattr(-,root,root,-)
%{_docdir}/%{name}-doc/

%changelog
openSUSE Build Service is sponsored by