File OpenUSD.spec of Package OpenUSD

# Copyright (c) 2021 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/
#


%bcond_with draco
%bcond_with ptex
%bcond_without materialx
%bcond_with vulkan
%bcond_without embree
%global usd_prefix %{_libdir}/%{name}
%global __builder ninja

#if 0#{?suse_version} == 1500
%global force_gcc_version 14
#endif

Name:           OpenUSD
Version:        23.02
Release:        0
Summary:        Universal Scene Description
License:        Apache-2.0
URL:            https://www.openusd.org/
Source99:       OpenUSD-rpmlintrc
#Patch1:         system-tbb.patch
Patch2:         py313.patch
# embree4 support https://github.com/PixarAnimationStudios/OpenUSD/pull/2313
Patch3:         2313.diff
Patch4:         vulkan-find.patch
BuildRequires:  ninja
BuildRequires:  alembic-devel
BuildRequires:  boost-devel
BuildRequires:  cmake >= 3.12
BuildRequires:  gcc%{?force_gcc_version}-c++
BuildRequires:  gcc%{?force_gcc_version}
BuildRequires:  libboost_program_options-devel
BuildRequires:  libboost_python3-devel
BuildRequires:  openvdb-devel
BuildRequires:  pkgconfig
BuildRequires:  %{primary_python}-Jinja2
BuildRequires:  %{primary_python}-devel
BuildRequires:  %{primary_python}-opengl
BuildRequires:  %{primary_python}-pyside6-devel
BuildRequires:  cmake(OSL)
%if %{with embree}
BuildRequires:  cmake(embree)
%endif
BuildRequires:  cmake(OpenColorIO)
%if %{with materialx}
BuildRequires:  cmake(MaterialX)
%endif
BuildRequires:  cmake(OpenEXR)
BuildRequires:  cmake(OpenImageIO)
BuildRequires:  cmake(OpenSubdiv)
BuildRequires:  cmake(TBB)
BuildRequires:  pkgconfig(gl)
BuildRequires:  pkgconfig(opengl)
BuildRequires:  hdf5-devel
%if %{with vulkan}
BuildRequires:  pkgconfig(vulkan)
BuildRequires:  cmake(glslang)
BuildRequires:  shaderc
BuildRequires:  VulkanMemoryAllocator-devel
%endif

%description
TODO

%package devel
Summary:  TODO
RequireS:  %{name} = %{version}
Requires:  cmake(MaterialX)
Requires:  cmake(OpenEXR)

%description devel
TODO

%prep
mv %{_sourcedir}/%{name}-%{version} %{_builddir}/%{name}-%{version}
%autosetup -p1 -D -T 0

%build
%global _lto_cflags %{nil}
# rm cmake/modules/FindTBB.cmake
%if 0%{?force_gcc_version}
export CC="gcc-%{?force_gcc_version}"
export CXX="g++-%{?force_gcc_version}"
%endif

%cmake \
  -DCMAKE_INSTALL_PREFIX:PATH=%{usd_prefix} \
  -DLIB_INSTALL_DIR:PATH=%{usd_prefix}/%{_lib} \
  -DSHARE_INSTALL_PREFIX:PATH=%{usd_prefix}/share \
  -DPYSIDEUICBINARY=%{_libexecdir}/qt6/uic \
  -DPYTHON_EXECUTABLE:FILEPATH=%{_bindir}/python3 \
  -DPXR_BUILD_ALEMBIC_PLUGIN:BOOL=ON \
  -DPXR_BUILD_DOCUMENTATION:BOOL=OFF \
  %if %{with draco}
  -DPXR_BUILD_DRACO_PLUGIN:BOOL=ON \
  %else
  -DPXR_BUILD_DRACO_PLUGIN:BOOL=OFF \
  %endif
  %if %{with embree}
  -DPXR_BUILD_EMBREE_PLUGIN:BOOL=ON \
  %else
  -DPXR_BUILD_EMBREE_PLUGIN:BOOL=OFF \
  %endif
  -DPXR_BUILD_EXAMPLES:BOOL=ON \
  -DPXR_BUILD_IMAGING:BOOL=ON \
  -DPXR_BUILD_OPENCOLORIO_PLUGIN:BOOL=ON \
  -DPXR_BUILD_OPENIMAGEIO_PLUGIN:BOOL=ON \
  -DPXR_BUILD_PRMAN_PLUGIN:BOOL=OFF \
  -DPXR_BUILD_TESTS:BOOL=OFF \
  -DPXR_BUILD_TUTORIALS:BOOL=ON \
  -DPXR_BUILD_USDVIEW:BOOL=ON \
  -DPXR_BUILD_USD_IMAGING:BOOL=ON \
  -DPXR_BUILD_USD_TOOLS:BOOL=ON \
  -DPXR_BUILD_USD_VALIDATION:BOOL=ON \
  -DPXR_ENABLE_GL_SUPPORT:BOOL=ON \
  -DPXR_ENABLE_HDF5_SUPPORT:BOOL=ON \
  %if %{with materialx}
  -DPXR_ENABLE_MATERIALX_SUPPORT:BOOL=ON \
  %else
  -DPXR_ENABLE_MATERIALX_SUPPORT:BOOL=OFF \
  %endif
  -DPXR_ENABLE_NAMESPACES:BOOL=ON \
  -DPXR_ENABLE_OPENVDB_SUPPORT:BOOL=ON \
  -DPXR_ENABLE_OSL_SUPPORT:BOOL=ON \
  %if %{with ptex}
  -DPXR_ENABLE_PTEX_SUPPORT:BOOL=ON \
  %else
  -DPXR_ENABLE_PTEX_SUPPORT:BOOL=OFF \
  %endif
  -DPXR_ENABLE_PYTHON_SUPPORT:BOOL=ON \
  %if %{with vulkan}
  -DPXR_ENABLE_VULKAN_SUPPORT:BOOL=ON \
  %else
  -DPXR_ENABLE_VULKAN_SUPPORT:BOOL=OFF \
  %endif
  -DPXR_PREFER_SAFETY_OVER_SPEED:BOOL=ON \
  -DPXR_VALIDATE_GENERATED_CODE:BOOL=ON
%cmake_build

%install
%cmake_install

mkdir -p %{buildroot}%{_libdir}/cmake/pxr/ %{buildroot}%{_bindir} %{buildroot}%{_includedir} %{buildroot}%{usd_prefix}/cmake/pxr/
mv -i \
  %{buildroot}%{usd_prefix}/pxrConfig.cmake \
  %{buildroot}%{usd_prefix}/cmake/pxrTargets.cmake \
  %{buildroot}%{usd_prefix}/cmake/pxrTargets-relwithdebinfo.cmake \
  %{buildroot}%{usd_prefix}/cmake/pxr/

ln -sf %{usd_prefix}/cmake/pxr/{pxrConfig.cmake,pxrTargets.cmake,pxrTargets-relwithdebinfo.cmake} %{buildroot}%{_libdir}/cmake/pxr/

ln -sf \
    %{usd_prefix}/bin/{hdGenSchema,sdfdump,sdffilter,testusdview,usdBakeMaterialX,usdGenSchema,usdInitSchema,usdcat,usdchecker,usddiff,usddumpcrate,usdedit,usdfixbrokenpixarschemas,usdgenschemafromsdr,usdmeasureperformance,usdrecord,usdresolve,usdstitch,usdstitchclips,usdtree,usdview,usdzip} \
  %{buildroot}%{_bindir}

# mv \
#     %{buildroot}%{materialx_prefix}/include/* \
#   %{buildroot}%{_includedir}/

%check
%ctest

%files
%dir %{usd_prefix}
%{usd_prefix}/bin/
%{usd_prefix}/lib/
%{usd_prefix}/plugin/
%{usd_prefix}/share/
%{_bindir}/hdGenSchema
%{_bindir}/sdfdump
%{_bindir}/sdffilter
%{_bindir}/testusdview
%{_bindir}/usdBakeMaterialX
%{_bindir}/usdGenSchema
%{_bindir}/usdInitSchema
%{_bindir}/usdcat
%{_bindir}/usdchecker
%{_bindir}/usddiff
%{_bindir}/usddumpcrate
%{_bindir}/usdedit
%{_bindir}/usdfixbrokenpixarschemas
%{_bindir}/usdgenschemafromsdr
%{_bindir}/usdmeasureperformance
%{_bindir}/usdrecord
%{_bindir}/usdresolve
%{_bindir}/usdstitch
%{_bindir}/usdstitchclips
%{_bindir}/usdtree
%{_bindir}/usdview
%{_bindir}/usdzip

%files devel
%{usd_prefix}/include/
%dir %{usd_prefix}/cmake
%{usd_prefix}/cmake/pxr/
%{_libdir}/cmake/pxr/

%changelog
openSUSE Build Service is sponsored by