File USD.spec of Package USD

#
# spec file for package USD
#
# Copyright (c) 2020 SUSE LINUX GmbH, Nuernberg, Germany.
# Copyright (c) 2020 LISA GmbH, Bingen, Germany.
#
# 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/
#


%define pkgver %(v=%version; echo -n "${v//\./_}")
%define libname libusd%{pkgver}

Name:           USD
Version:        20.05
Release:        0
Summary:        Universal Scene Description
License:        Apache-2.0
Group:          Productivity/Graphics/Visualization
URL:            https://openusd.org
Source:         https://github.com/PixarAnimationStudios/%{name}/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
Patch0:         usd-fixes.patch
BuildRequires:  alembic-devel
BuildRequires:  OpenColorIO-devel
BuildRequires:  OpenEXR-devel
BuildRequires:  OpenImageIO-devel
BuildRequires:  OpenShadingLanguage-devel
BuildRequires:  OpenSubdiv-devel
BuildRequires:  libboost_program_options-devel
BuildRequires:  libboost_python3-devel
#BuildRequires:  clang
#BuildRequires:  clang-devel
BuildRequires:  cmake >= 2.8.8
BuildRequires:  gcc-c++
BuildRequires:  pkgconfig
BuildRequires:  python3
BuildRequires:  python3-devel
BuildRequires:  python3-Jinja2
BuildRequires:  python3-opengl
BuildRequires:  tbb-devel
BuildRequires:  libtbbmalloc2
BuildRequires:  pkgconfig(gl)
BuildRequires:  pkgconfig(glew)
BuildRequires:  pkgconfig(glu)
BuildRequires:  pkgconfig(glut)
BuildRequires:  pkgconfig(Ptex)
BuildRequires:  python-rpm-macros
BuildRequires:  openvdb-devel
BuildRequires:  pkgconfig(blosc)
BuildRequires:  hdf5-devel
#BuildRequires:  embree-devel-static
ExclusiveArch:  x86_64

%description
Universal Scene Description (USD) is an efficient, scalable system for
authoring, reading, and streaming time-sampled scene description for
interchange between graphics applications.

%package -n %{libname}
Summary:        Universal Scene Description library
Group:          System/Libraries

%description -n %{libname}
Universal Scene Description (USD) is an efficient, scalable system for
authoring, reading, and streaming time-sampled scene description for
interchange between graphics applications.

%package devel
Summary:        Development files for USD
Group:          Development/Libraries/C and C++
Requires:       %{libname} = %{version}

%description devel
This package contains the C++ header files and symbolic links to the shared
libraries for %{name}. If you would like to develop programs using %{name},
you will need to install %{name}-devel.

%prep
%autosetup -p1

%build
#    -DCMAKE_C_COMPILER="clang" \
#    -DCMAKE_CXX_COMPILER="clang++" \
#    USD expects embree as shared lib
#    -DPXR_BUILD_EMBREE_PLUGIN=ON \
#    -DEMBREE_INCLUDE_DIR=%%{_includedir}/embree3 \
%cmake --trace \
    -DCMAKE_VERBOSE_MAKEFILE=ON \
    -DCMAKE_SKIP_RPATH=ON \
    -DCMAKE_SKIP_INSTALL_RPATH=ON \
    -DCMAKE_EXE_LINKER_FLAGS:STRING="-pie" \
    -DPXR_BUILD_TESTS=OFF \
    -DPXR_BUILD_EXAMPLES=OFF \
    -DPXR_BUILD_TUTORIALS=OFF \
    -DPXR_BUILD_OPENIMAGEIO_PLUGIN=ON \
    -DPXR_BUILD_OPENCOLORIO_PLUGIN=ON \
    -DPXR_BUILD_USDVIEW=OFF \
    -DPXR_BUILD_ALEMBIC_PLUGIN=ON \
    -DPXR_USE_PYTHON_3=ON \
    -DPXR_ENABLE_OSL_SUPPORT=ON \
    -DPXR_ENABLE_PTEX_SUPPORT=ON \
    -DPXR_ENABLE_OPENVDB_SUPPORT=ON \
    -DTBB_tbb_LIBRARY=%{_libdir}/libtbb.so

# if testing is enabled, we need this to fix linking a single plugin (that's supposed to be using an unresolvable symbol)
# but our default linker options contain -Wl,--no-undefined.
# simply fixing pxr/base/plug/CMakeLists.txt isn't enough, because set_target_properties(LINK_FLAGS) is only able to add
# flags, and those appear before any default link options. ld seems to prefer the latter options over the former.
# we cannot get any dirtier..
#sed -i 's|-Wl,--no-undefined|-Wl,--undefined,dynamic_lookup|g' pxr/base/plug/CMakeFiles/TestPlugDsoUnloadable.dir/link.txt

make %{?_smp_mflags}

%install
%cmake_install
# todo: fix installation: see usd-fixes.patch
# major road block: none of the shared libs are versionized.

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

%files
%license LICENSE.txt
%doc NOTICE.txt README.md
%{_bindir}/*
%dir %{_prefix}/plugin
%dir %{_prefix}/plugin/usd
%{_prefix}/plugin/usd/*
%dir %{_datadir}/usd
%dir %{_datadir}/usd/examples
%dir %{_datadir}/usd/examples/plugin
%{_datadir}/usd/examples/plugin/*
%dir %{python_sitearch}/pxr
%{python_sitearch}/pxr/

%files -n %{libname}
%license LICENSE.txt
%doc NOTICE.txt README.md
%{_libdir}/*.so.*

%files devel
%doc BUILDING.md CHANGELOG.md VERSIONS.md
%{_includedir}/pxr/
%{_libdir}/*.so
%{_datadir}/cmake/*

%changelog
openSUSE Build Service is sponsored by