File cpr.spec of Package cpr

#
# spec file for package cpr
#
# copyright (c) 2023 munix9@googlemail.com
#

%define sover 1
%define mongv 7.7

%ifarch %{ix86}
%bcond_with    tests
%else
%bcond_without tests
%endif

Name:           cpr
Version:        1.10.5
Release:        0
Summary:        Curl for People
License:        MIT
URL:            https://github.com/libcpr/cpr
Source0:        https://github.com/libcpr/cpr/archive/refs/tags/%{version}.tar.gz#/%{name}-%{version}.tar.gz
Source10:       https://github.com/cesanta/mongoose/archive/%{mongv}.tar.gz#/mongoose-%{mongv}.tar.gz
BuildRequires:  cmake
BuildRequires:  gcc-c++
BuildRequires:  pkgconfig
BuildRequires:  pkgconfig(gtest)
BuildRequires:  pkgconfig(libcurl)
BuildRequires:  pkgconfig(libssl)
BuildRequires:  pkgconfig(zlib)
%if 0%{?fedora_version}
BuildRequires:  ninja-build
%endif
%if 0%{?suse_version}
BuildRequires:  ninja
%endif

%description
C++ Requests is a simple wrapper around libcurl inspired by the
excellent Python Requests project.

%package -n lib%{name}%{sover}
Summary:        Curl for People

%description -n lib%{name}%{sover}
C++ Requests is a simple wrapper around libcurl inspired by the
excellent Python Requests project.

%package devel
Summary:        The development files for %{name}
Requires:       lib%{name}%{sover} = %{version}

%description devel
Additional header files for development with %{name}.

%prep
%autosetup -p1

# get mongoose src from local file
sed -e 's|URL .* https.*/cesanta/mongoose/.*\.tar\.gz$|URL file://%{SOURCE10}|' \
    -i CMakeLists.txt

%build
%define __builder ninja
CFLAGS="%{optflags} -Wno-error=deprecated-declarations"
%if 0%{?suse_version} <= 1500
CFLAGS+=" -pthread"
%endif
export CFLAGS
export CXXFLAGS="$CFLAGS"

%cmake \
	-DCPR_BUILD_TESTS=%{?with_tests:ON}%{!?with_tests:OFF} \
	-DCPR_BUILD_TESTS_PROXY=OFF \
	-DCPR_BUILD_TESTS_SSL=%{?with_tests:ON}%{!?with_tests:OFF} \
	-DCPR_DEBUG_SANITIZER_FLAG_ALL=ON \
	-DCPR_ENABLE_CURL_HTTP_ONLY=OFF \
	-DCPR_USE_SYSTEM_CURL=ON \
	-DCPR_USE_SYSTEM_GTEST=ON

%cmake_build

%install
%cmake_install

%check
%{!?with_tests:exit 0}
%ctest --parallel 1 --timeout 60 --verbose || :

%if 0%{?suse_version} > 1500
%ldconfig_scriptlets -n lib%{name}%{sover}
%else
%post   -n lib%{name}%{sover} -p /sbin/ldconfig
%postun -n lib%{name}%{sover} -p /sbin/ldconfig
%endif

%files -n lib%{name}%{sover}
%license LICENSE
%doc README.md
%{_libdir}/lib%{name}.so.*

%files devel
%{_includedir}/%{name}
%{_libdir}/cmake/%{name}
%{_libdir}/lib%{name}.so

%changelog
openSUSE Build Service is sponsored by