File zxing-cpp-opt.spec of Package zxing-cpp-opt
#
# spec file for package zxing-cpp-opt
#
# Copyright (c) 2025 Dmitry Ivanov
#
# 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/
#
%global sover 3
# OpenSUSE Leap by default ships with gcc which is too old to build
# zxing-cpp-opt, so require gcc-13
%if 0%{?sle_version} == 150600 && 0%{?is_opensuse} && 0%{?gcc_version} < 13
%define with_gcc 13
%endif
# Disable generation of debuginfo package for Fedora >= 41
%if 0%{?fedora_version} >= 41
%global debug_package %{nil}
%endif
Name: zxing-cpp-opt
Version: 2.3.0
Release: 0
Summary: C++ port of ZXing
License: Apache-2.0
URL: https://github.com/zxing-cpp/zxing-cpp
Source0: %{name}-%{version}.tar.gz
BuildRequires: bash
BuildRequires: binutils
BuildRequires: gcc%{?with_gcc}
BuildRequires: gcc%{?with_gcc}-c++
BuildRequires: cmake
%if 0%{?fedora_version}
BuildRequires: ninja-build
%else
BuildRequires: ninja
%endif
ExclusiveArch: x86_64
%description
ZXing-C++ ("zebra crossing") is an open-source, multi-format linear/matrix barcode image processing library implemented in C++.
%package -n libZXing-opt-%{sover}
Summary: C++ port of ZXing
Group: Development/Libraries/C and C++
%description -n libZXing-opt-%{sover}
ZXing-C++ ("zebra crossing") is an open-source, multi-format linear/matrix barcode image processing library implemented in C++.
%package devel
Summary: Development files for %{name}
Requires: libZXing-opt-%{sover} = %{version}-%{release}
%description devel
Files for developing applications that use %{name}.
%prep
%autosetup
%build
%if 0%{?with_gcc}
export CXX=g++-%{with_gcc}
export CC=gcc-%{with_gcc}
%endif
export CXXFLAGS="%{optflags} -std=c++17"
%cmake \
-DCMAKE_INSTALL_PREFIX=/opt/zxing-cpp \
-DCMAKE_CXX_EXTENSIONS=ON \
%if 0%{?suse_version} > 1500
-DBUILD_C_API=ON \
%endif
-DBUILD_EXAMPLES=OFF
%cmake_build
%install
%cmake_install
strip %{buildroot}/opt/zxing-cpp/%{_lib}/libZXing.so.%{sover}
# SLE12 does not define this macro
%if %{undefined ldconfig_scriptlets}
%post -n libZXing-opt-%{sover} -p /sbin/ldconfig
%postun -n libZXing-opt-%{sover} -p /sbin/ldconfig
%else
%ldconfig_scriptlets -n libZXing-opt-%{sover}
%endif
%files -n libZXing-opt-%{sover}
%defattr(-,root,root)
%dir /opt/zxing-cpp
%dir /opt/zxing-cpp/%{_lib}
/opt/zxing-cpp/%{_lib}/libZXing.so.*
%files devel
%dir /opt/zxing-cpp/include
%dir /opt/zxing-cpp/include/ZXing
%dir /opt/zxing-cpp/%{_lib}/cmake
%dir /opt/zxing-cpp/%{_lib}/pkgconfig
/opt/zxing-cpp/include/ZXing/*
/opt/zxing-cpp/%{_lib}/libZXing.so
/opt/zxing-cpp/%{_lib}/cmake/*
/opt/zxing-cpp/%{_lib}/pkgconfig/*
%changelog
* Mon Feb 3 2025 Dmitry Ivanov dm.vl.ivanov@gmail.com
- Initial version