File glslang.spec of Package glslang

%define realname glslang
%define realver  1.4.321.0
%define srcext   tar.gz

%bcond_without shared

# See CHANGES.md
%define lib_ver  15.4.0
%define so_ver   15

# Common info
Name:          %{realname}
Version:       %{lib_ver}
Release:       wiz%{?extraver:0.}1%{?dist}
License:       BSD-3-Clause
Group:         System/Libraries
URL:           https://github.com/KhronosGroup/glslang
Summary:       Front end for GLSL/ESSL, partial front end for HLSL, and a SPIR-V generator

BuildRequires: cmake >= 2.8.12
BuildRequires: ninja
BuildRequires: gcc-c++
BuildRequires: python3%{?suse_version:-base}
BuildRequires: spirv-tools-devel = 2025.1
Source0:       https://github.com/KhronosGroup/glslang/archive/refs/tags/vulkan-sdk-%{realver}%{?extraver}.%{srcext}#/%{realname}-%{realver}%{?extraver}.%{srcext}

%description
Khronos-reference front end for GLSL/ESSL, partial front end for HLSL,
and a SPIR-V generator.

%if %{with shared}
%package -n lib%{realname}%{so_ver}
Group:         System/Libraries
Summary:       Front end for GLSL/ESSL, partial front end for HLSL, and a SPIR-V generator

%description -n lib%{realname}%{so_ver}
Khronos-reference front end for GLSL/ESSL, partial front end for HLSL,
and a SPIR-V generator.

%files -n lib%{realname}%{so_ver}
%defattr(-,root,root)
%license LICENSE.txt
%{_libdir}/*.so.%{?so_ver}*

%post   -n lib%{realname}%{so_ver} -p /sbin/ldconfig
%postun -n lib%{realname}%{so_ver} -p /sbin/ldconfig
%endif

%package devel
Group:         Development/Languages/C and C++
Summary:       Development files for %{name}
Provides:      lib%{realname}-devel = %{lib_ver}-%{release}
%if %{with shared}
Provides:      lib%{realname}%{so_ver}-devel = %{lib_ver}-%{release}
Requires:      lib%{realname}%{so_ver} = %{lib_ver}-%{release}
%endif

%description devel
Development files for %{name}

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

%build
_CFLAGS='%{optflags} %{?gcc_lto:%{gcc_lto}%{!?with_shared: -ffat-lto-objects}}'
_LDFLAGS='-Wl,--as-needed -Wl,--strip-all -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro %{?gcc_lto:%{gcc_lto}%{!?with_shared: -ffat-lto-objects}}'
_CMAKE_ARGS=(
 -Wno-dev
 -G Ninja
 -DCMAKE_INSTALL_PREFIX=%{_prefix}
 -DCMAKE_INSTALL_LIBDIR=%{_libdir}
 -DCMAKE_BUILD_TYPE=RelWithDebInfo
 -DCMAKE_C_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
 -DCMAKE_POLICY_VERSION_MINIMUM=3.5
)
cmake -S . -B build \
 "${_CMAKE_ARGS[@]}" \
%if %{with shared}
 -DBUILD_SHARED_LIBS=YES \
%endif
 -DGLSLANG_TESTS=NO \
 -DBUILD_EXTERNAL=NO \
 -DALLOW_EXTERNAL_SPIRV_TOOLS=YES
ninja -v -C build %{?_smp_mflags}

%install
DESTDIR=%{buildroot} ninja -v -C build install
%{__rm} -rf %{buildroot}%{_includedir}/SPIRV
%{__ln_s} -fn glslang/SPIRV %{buildroot}%{_includedir}/
find build -name \*.a -exec %{__install} {} %{buildroot}%{_libdir}/ \;

# Files
%files
%defattr(-,root,root)
%license LICENSE.txt
%doc CODE_OF_CONDUCT.md README-spirv-remap.txt README.md
%{_bindir}/glslang
%{_bindir}/glslangValidator
%{_bindir}/spirv-*

# Development stuff
%files devel
%defattr(-,root,root)
%license LICENSE.txt
%doc CODE_OF_CONDUCT.md README-spirv-remap.txt README.md
%{_includedir}/%{realname}
%{_includedir}/SPIRV
%dir %{_libdir}/cmake/glslang
%dir %{_libdir}/cmake
%{_libdir}/cmake/glslang/*.cmake
%if %{with shared}
%{_libdir}/*.so
%endif
%{_libdir}/*.a

%changelog
openSUSE Build Service is sponsored by