File universal.spec of Package universal

# Spec file for the universal C++ library
#
# This spec file is designed for the OpenSUSE Build Service (OBS)
# and follows standard packaging guidelines.

Name:           universal
# The version will be automatically set by the OBS service based on the git commit.
Version:        3.3.0
Release:        0
Summary:        A C++ library for universal number arithmetic
License:        MIT
URL:            https://github.com/stillwater-sc/universal
# The source tarball is generated by the OBS service from the git repository.
Source0:        %{name}-%{version}.tar.gz

# -- Build Dependencies --
# The project uses CMake as its build system.
BuildRequires:  cmake >= 3.10
BuildRequires:  gcc14-c++
# Project dependencies identified from CMakeLists.txt
BuildRequires:  boost-devel
BuildRequires:  gmp-devel
BuildRequires:  mpfr-devel

# =================================================================
# BASE PACKAGE
# =================================================================

%description
The Universal library is a C++ template library for number systems and arbitrary precision arithmetic. It provides a foundational set of classes and functions to work with different number systems, enabling their use in any C++ program.

This package contains the runtime components needed to run applications built with the universal library.

# =================================================================
# DEVELOPMENT PACKAGE
# =================================================================

%package devel
Summary:        Development files for the universal C++ library
Requires:       %{name} = %{version}-%{release}

%description devel
The Universal library is a C++ template library for number systems and arbitrary precision arithmetic. It provides a foundational set of classes and functions to work with different number systems, enabling their use in any C++ program.

This package contains the headers, static library, and CMake configuration files required to develop applications using the universal library.

# =================================================================
# BUILD AND INSTALL SECTIONS
# =================================================================

%prep
# Unpack the source tarball generated by the service.
%autosetup
# This sed command adjusts the installation path for headers to include 'sw/' subdirectory
sed -i 's|}/include/|}/include/sw/|g' CMakeLists.txt

%build
# Set the compiler to GCC 14
export CXX=g++-14
export CC=gcc-14
# Configure the project with CMake.
# We build shared libs for proper package splitting.
# We disable tests, examples, and benchmarks as they are not needed for the final package.
%cmake \
    -DBUILD_ALL=ON \
    -DBUILD_SHARED_LIBS=ON \
    -DBUILD_TESTING=OFF \
    -DCMAKE_INSTALL_PREFIX:PATH=/usr \
    -DUNIVERSAL_BUILD_EXAMPLES=OFF \
    -DUNIVERSAL_BUILD_TESTS=OFF \
    -DUNIVERSAL_BUILD_BENCHMARKS=OFF

# Compile the project using the generated Makefiles.
%cmake_build

%install
# Install the compiled files into the build root.
%cmake_install
cp -a include/sw/blas %{buildroot}%{_includedir}/universal
cp -a include/sw/math %{buildroot}%{_includedir}/universal
cp -a include/sw/numeric %{buildroot}%{_includedir}/universal

# =================================================================
# FILE LISTS
# =================================================================

%files
# Files for the base runtime package
%license LICENSE
%doc README.md
%{_bindir}/*
#% {_libdir}/*.so.*
%{_datadir}/%{name}/

%files devel
# Files for the development package
%{_includedir}/universal/blas/
%{_includedir}/universal/math/
%{_includedir}/universal/numeric/
%{_includedir}/universal/
#% {_libdir}/*.so
#% {_libdir}/*.a
#% {_libdir}/cmake/universal/

%changelog
# spec file created and split into base and -devel packages
openSUSE Build Service is sponsored by