File flatbuffers.spec of Package flatbuffers
#
# spec file for package flatbuffers
#
# Copyright (c) 2020 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/
#
%define sonum 25_9_23
Name: flatbuffers
Version: 25.x.x
Release: 0
Summary: Memory Efficient Serialization Library
License: Apache-2.0
Group: Development/Libraries/C and C++
URL: https://google.github.io/flatbuffers/
Source0: %{name}-%{version}.tar.xz
BuildRequires: cmake >= 3.12
%if 0%{?suse_version} <= 1600
BuildRequires: gcc14
BuildRequires: gcc14-c++
%else
BuildRequires: gcc-c++
%endif
%description
FlatBuffers is a serialization library for games and other memory constrained programs.
FlatBuffers allows to directly access serialized data without unpacking/parsing
it first, while still having great forwards/backwards compatibility.
%package -n libflatbuffers%{sonum}
Summary: Memory Efficient Serialization Library
Group: System/Libraries
Provides: libflatbuffers = %{version}
%description -n libflatbuffers%{sonum}
FlatBuffers is a serialization library for games and other memory constrained programs.
FlatBuffers allows to directly access serialized data without unpacking/parsing
it first, while still having great forwards/backwards compatibility.
This package provides the libflatbuffers shared library.
%package devel
Summary: Development files for %{name}
Group: Development/Libraries/C and C++
Requires: libflatbuffers%{sonum} = %{version}
Provides: %{name}-devel-static = %{version}
%description devel
FlatBuffers is a serialization library for games and other memory constrained programs.
FlatBuffers allows to directly access serialized data without unpacking/parsing
it first, while still having great forwards/backwards compatibility.
This package provides the libflatbuffers headers, development libraries,
and tools.
%prep
%autosetup -p1
%build
# Fixup CMake/FlatbuffersConfigVersion.cmake.in - Upstream releases tarballs
# that make no sense. They exect git describe to find correct information about
# the version in use - and replace that into the cmake file in the end. Obviously
# the tarball has no .git directory and thus does not carry that inormation
# We just inject %%version there. Easiest fix.
#sed -i 's|@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@|%{version}|' CMake/FlatBuffersConfigVersion.cmake.in
export CFLAGS="%optflags -flto=auto"
export CXXFLAGS="%optflags -flto=auto"
export LDFLAGS="$(CFLAGS) ${LDFLAGS}"
%if 0%{?suse_version} <= 1600
test -x "$(type -p gcc-14)" && export CC="$_"
test -x "$(type -p g++-14)" && export CXX="$_"
%endif
%cmake -DCMAKE_BUILD_TYPE=Release \
-DFLATBUFFERS_BUILD_SHAREDLIB=ON \
-DFLATBUFFERS_BUILD_FLATLIB=OFF \
-DFLATBUFFERS_BUILD_FLATC=ON \
-DFLATBUFFERS_BUILD_CPP17=ON \
-DFLATBUFFERS_BUILD_TESTS=OFF
%cmake_build
%install
%cmake_install
mkdir -p %{buildroot}/%{_datadir}/cmake/Modules
install -Dm0644 CMake/*FlatBuffers.cmake %{buildroot}%{_datadir}/cmake/Modules/
%check
%ctest
%post -n libflatbuffers%{sonum} -p /sbin/ldconfig
%postun -n libflatbuffers%{sonum} -p /sbin/ldconfig
%files -n libflatbuffers%{sonum}
%license LICENSE
%{_libdir}/libflatbuffers.so.*
%files devel
%doc README.md docs/
%{_bindir}/flatc
%{_libdir}/libflatbuffers.so
%{_includedir}/flatbuffers/
%{_libdir}/cmake/flatbuffers/
%{_datadir}/cmake/Modules/*FlatBuffers.cmake
%{_libdir}/pkgconfig/flatbuffers.pc
%changelog