File forge.spec of Package forge

#
# spec file for package forge
#
# Copyright (c) 2022 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/
#

# forge has support for two windowing toolkits, either GLFW (default) or SDL2
%bcond_with sdl2
# Sphix too old in Leap <= 15.4
%if 0%{?suse_version} >= 1550
%bcond_without docs
%else
%bcond_with    docs
%endif

%define glad_ver 0+git20210420.b94680a

Name:           forge
%define libname libforge
%define sonum 1

Summary:        High Performance Visualization Library
License:        BSD-3-Clause
Group:          Productivity/Scientific/Other
Version:        1.0.8
Release:        0
Url:            https://github.com/arrayfire/forge
Source0:        https://github.com/arrayfire/forge/archive/v%{version}.tar.gz#/forge-%{version}.tar.gz
# forge needs a complete git clone, generate via _service
Source1:        glad-%{glad_ver}.tar.xz
BuildRequires:  cmake >= 3.5
BuildRequires:  gcc-c++
BuildRequires:  freeimage-devel
BuildRequires:  git-core
BuildRequires:  glm-devel
BuildRequires:  libboost_headers-devel
BuildRequires:  opencl-cpp-headers
BuildRequires:  pkgconfig
BuildRequires:  pkgconfig(fontconfig)
BuildRequires:  pkgconfig(freetype2)
BuildRequires:  pkgconfig(gl)
%if %{with sdl2}
BuildRequires:  pkgconfig(sdl2)
%else
BuildRequires:  pkgconfig(glfw3)
%endif
%if %{with docs}
BuildRequires:  doxygen
BuildRequires:  python3-Sphinx
BuildRequires:  python3-breathe
BuildRequires:  python3-recommonmark
%endif
# Old packages reused the version 3.3.2 from arrayfire
Obsoletes:      forge = 3.3.2

%description
A prototype of the OpenGL interop library that can be used with
ArrayFire. The goal of Forge is to provide high performance OpenGL
visualizations for C/C++ applications that use CUDA/OpenCL. Forge
uses OpenGL >=3.3 forward compatible contexts, so please make sure
you have capable hardware before trying it out.

%package -n %{libname}%{sonum}
Summary:        High Performance Visualization Library
Group:          System/Libraries

%description -n %{libname}%{sonum}
A prototype of the OpenGL interop library that can be used with
ArrayFire. The goal of Forge is to provide high performance OpenGL
visualizations for C/C++ applications that use CUDA/OpenCL. Forge
uses OpenGL >=3.3 forward compatible contexts, so please make sure
you have capable hardware before trying it out.

%package devel
Summary:        High Performance Visualization Library
Group:          Development/Libraries/C and C++
Requires:       %{libname}%{sonum} = %{version}
Requires:       cmake
Requires:       glm-devel
Requires:       pkgconfig(fontconfig)
Requires:       pkgconfig(freetype2)
%if %{with sdl2}
Requires:       pkgconfig(sdl2)
%else
Requires:       pkgconfig(glfw3)
%endif

%description devel
A prototype of the OpenGL interop library that can be used with
ArrayFire. The goal of Forge is to provide high performance OpenGL
visualizations for C/C++ applications that use CUDA/OpenCL. Forge
uses OpenGL >=3.3 forward compatible contexts, so please make sure
you have capable hardware before trying it out.

This package provides the development files and headers needed to
build packages using Forge.

%package doc
Summary:        Documentation for %{name}
Group:          Documentation/Other
Recommends:     %{name}-devel = %{version}
BuildArch:      noarch

%description doc
A prototype of the OpenGL interop library that can be used with
ArrayFire. The goal of Forge is to provide high performance OpenGL
visualizations for C/C++ applications that use CUDA/OpenCL. Forge
uses OpenGL >=3.3 forward compatible contexts, so please make sure
you have capable hardware before trying it out.

This package provides the documentation and help files for Forge.

%prep
%setup -q -T -b1 -n glad-%{glad_ver}
%setup -q -n forge-%{version}
rm -Rf extern
mkdir -p extern/cl2hpp
# Setup cl2hpp
ln -T -s /usr/include extern/cl2hpp/include
# Setup glad
ln -T -s ../../glad-%{glad_ver} extern/fg_glad-src
git config --global user.email "obs"
(cd extern/fg_glad-src/; git init -b origin/main; git add . ; git commit -m initial ; git tag obj_lib)


%build
%cmake \
    -DFETCHCONTENT_FULLY_DISCONNECTED:BOOL=ON \
    -DFETCHCONTENT_SOURCE_DIR_FG_GLAD=../../glad-%{glad_ver} \
    -DCMAKE_CXX_FLAGS="%{optflags}" \
    -DFG_BUILD_DOCS=%{?with_docs:ON}%{!?with_docs:OFF} \
    %{?with_sdl2:-DFG_USE_WINDOW_TOOLKIT=sdl2} \
    -DFG_INSTALL_LIB_DIR=%{_libdir} \
    -DFG_INSTALL_CMAKE_DIR=%{_libdir}/cmake/Forge/ \
    -DFG_INSTALL_DOC_DIR=%{_docdir}/%{name}/ \
    -DFG_INSTALL_EXAMPLE_DIR=%{_docdir}/%{name}/examples

%cmake_build

%install
%cmake_install
# cleanup non-deterministic sphinx cache
rm -rf %{buildroot}/%{_docdir}/%{name}/sphinx/.doctrees

%check
%ctest

%post -n %{libname}%{sonum} -p /sbin/ldconfig
%postun -n %{libname}%{sonum} -p /sbin/ldconfig

%files -n %{libname}%{sonum}
%{_libdir}/libforge.so.*

%files devel
%doc README.md
%{_libdir}/libforge.so
%{_libdir}/cmake/Forge/
%{_includedir}/forge.h
%{_includedir}/fg/

%files doc
%doc README.md
%dir %{_docdir}/%{name}/
%if %{with docs}
%{_docdir}/%{name}/sphinx/
%endif
%{_docdir}/%{name}/examples/


%changelog
openSUSE Build Service is sponsored by