File pulsar-client-cpp.spec of Package pulsar-client-cpp

#
# spec file for package pulsar-client-cpp
#
# Copyright (c) 2024 SUSE LLC
#
# 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/
#

# disable 32 bit builds
ExcludeArch: %{ix86} %{arm32}

# optionally build the static libraries
%bcond_with static_libs

# optionally allow building of tests
%bcond_with build_tests

# disable running tests by default - local docker instance required
%bcond_with run_tests

%if 0%{?sle_version} && 0%{?sle_version} < 160000
%define force_gcc_version 13
%endif

# pulsar library version suffix
%define so_sfx 3_6_0

# pulsar library name
%define lib_name pulsar

Name:           pulsar-client-cpp
Version:        3.6.0
Release:        0
Summary:        Pulsar C++ client library
Group:          Development/Languages/C and C++
License:        Apache-2.0
URL:            https://github.com/apache/pulsar-client-cpp
Source0:        https://github.com/apache/pulsar-client-cpp/archive/refs/tags/v%{version}.tar.gz#/pulsar-client-cpp-%{version}.tar.xz
Source100:      %{name}-rpmlintrc
# PATCH-FIX-OPENSUSE library_install_paths_fix.patch
Patch0:         library_install_paths_fix.patch
# PATCH-FIX-OPENSUSE fat_lto_objects_compiler_flag.patch
Patch1:         fat_lto_objects_compiler_flag.patch
BuildRequires:  cmake
BuildRequires:  gcc%{?force_gcc_version}
BuildRequires:  gcc%{?force_gcc_version}-c++
BuildRequires:  boost-devel
BuildRequires:  libcurl-devel
BuildRequires:  libopenssl-1_1-devel
BuildRequires:  libzstd-devel
BuildRequires:  protobuf-devel < 26
BuildRequires:  snappy-devel
BuildRequires:  zlib-devel
%if %{with buiid_tests} || %{with run_tests}
# SECTION test requirements
BuildRequires:  cmake(GTest)
BuildRequires:  git
# /SECTION
%endif

%description
The Apache Pulsar C++ client supports a variety of Apache Pulsar features
to enable building applications connecting to your Apache Pulsar cluster.

%package        devel
Summary:        Development files for Apache Pulsar
Requires:       lib%{lib_name}%{so_sfx} = %{version}
%if %{with static_libs}
Suggests:       %{name}-devel-static  = %{version}
%endif

%description    devel
The Apache Pulsar C++ client supports a variety of Apache Pulsar features
to enable building applications connecting to your Apache Pulsar cluster.

This package provides the development libraries and headers for Apache
Pulsar.

%if %{with static_libs}
%package        devel-static
Summary:        Development files for Apache Pulsar
Requires:       lib%{lib_name}%{so_sfx} = %{version}

%description    devel-static
The Apache Pulsar C++ client supports a variety of Apache Pulsar features
to enable building applications connecting to your Apache Pulsar cluster.

This package provides the static library for Apache Pulsar.
%endif

%package -n     lib%{lib_name}%{so_sfx}
Summary:        Development files for Apache Pulsar - shared library

%description -n lib%{lib_name}%{so_sfx}
The Apache Pulsar C++ client supports a variety of Apache Pulsar features
to enable building applications connecting to your Apache Pulsar cluster.

This package provides the shared library for Apache Arrow.

%prep
%autosetup -p1 -n pulsar-client-cpp-%{version}

%build
export PULSAR_LIBRARY_VERSION=%{version}
%cmake \
%if 0%{?force_gcc_version}
    -DCMAKE_C_COMPILER=gcc-%{force_gcc_version} \
    -DCMAKE_CXX_COMPILER=g++-%{force_gcc_version} \
%endif
    -DCMAKE_CXX_STANDARD=14 \
%if %{without static_libs}
    -DBUILD_STATIC_LIB:BOOL=OFF \
%endif
%if %{without buiid_tests}
    -DBUILD_TESTS:BOOL=OFF \
%endif
%{nil}

%cmake_build

%install
%cmake_install

%check
# run pulsar unit tests if enabled
# NOTE: pulsar unit tests require docker to run
%if %{with run_tests}
export RETRY_FAILED=3
./run-unit-tests.sh
%endif

# run pulsar service based tests if enabled
# NOTE: pulsar service based tests require docker to run
%if 0%{with run_tests}
./pulsar-test-service-start.sh
pushd tests
./pulsar-tests
popd
./pulsar-test-service-stop.sh
%endif

%ldconfig_scriptlets -n lib%{lib_name}%{so_sfx}

%files devel
%doc README.md
%license LICENSE NOTICE
%dir %{_includedir}/pulsar
%{_includedir}/pulsar/*.h
%dir %{_includedir}/pulsar/c/
%{_includedir}/pulsar/c/*.h
%{_libdir}/lib%{lib_name}.so

%if %{with static_libs}
%files devel-static
%doc README.md
%license LICENSE NOTICE
%{_libdir}/lib%{lib_name}.a
%endif

%files -n lib%{lib_name}%{so_sfx}
%doc README.md
%license LICENSE NOTICE
%{_libdir}/lib%{lib_name}.so.%{version}

%changelog
openSUSE Build Service is sponsored by