File spirv-headers.spec of Package spirv-headers

%define realname SPIRV-Headers
%define realver  1.4.321.0
%define srcext   tar.gz

# Common info
Name:          spirv-headers
Version:       %{realver}
Release:       wiz%{?extraver:0.}1%{?dist}
License:       MIT
Group:         Development/Languages/C and C++
URL:           https://github.com/KhronosGroup/SPIRV-Headers
Summary:       SPIRV-Headers

# Install-time parameters
Provides:      %{realname} = %{version}-%{release}
Obsoletes:     %{realname} < %{version}-%{release}

# Build-time parameters
BuildRequires: cmake >= 3.0
BuildRequires: pkg-config
BuildRequires: gcc-c++
BuildRequires: ninja
BuildRoot:     %{_tmppath}/%{name}-root
BuildArch:     noarch
Source0:       https://github.com/KhronosGroup/SPIRV-Headers/archive/refs/tags/vulkan-sdk-%{realver}%{?extraver}.%{srcext}#/%{realname}-%{realver}%{?extraver}.%{srcext}

%description
This package contains machine-readable files for the SPIR-V Registry.
This includes:

  * Header files for various languages.
  * JSON files describing the grammar for the SPIR-V core instruction set and
    the extended instruction sets.
  * The XML registry file.
  * A tool to build the headers from the JSON grammar.

# Preparation step (unpackung and patching if necessary)
%prep
%setup -q -n %{realname}-vulkan-sdk-%{realver}%{?extraver}

# Build step (compile/build binaries, documentation, etc)
%build
_CMAKE_ARGS=(
 -Wno-dev
 -G Ninja
 -DCMAKE_INSTALL_PREFIX=%{_prefix}
 -DCMAKE_BUILD_TYPE=Release
 -DCMAKE_C_FLAGS_RELEASE="$_CFLAGS"
 -DCMAKE_CXX_FLAGS_RELEASE="$_CFLAGS"
 -DCMAKE_EXE_LINKER_FLAGS_RELEASE="$_LDFLAGS"
 -DCMAKE_MODULE_LINKER_FLAGS_RELEASE="$_LDFLAGS"
 -DCMAKE_SHARED_LINKER_FLAGS_RELEASE="$_LDFLAGS"
 -DCMAKE_VERBOSE_MAKEFILE=YES
)
cmake -S . -B tmp_build \
 "${_CMAKE_ARGS[@]}"
ninja -v -C tmp_build %{?_smp_mflags}

# Install built stuff
%install
DESTDIR=%{buildroot} ninja -v -C tmp_build install

# Cleanup
%clean
[ "%{buildroot}" != "/" ] && %{__rm} -rf %{buildroot}

# Files list
%files
%defattr(-,root,root)
%license LICENSE
%doc README.md
%{_includedir}/spirv/
%{_datadir}/pkgconfig/%{realname}.pc
%dir %{_datadir}/cmake/SPIRV-Headers
%dir %{_datadir}/cmake
%{_datadir}/cmake/SPIRV-Headers/*.cmake

%changelog
openSUSE Build Service is sponsored by