File netgen.spec of Package netgen

# spec file for package netgen
# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, 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

%bcond_with need_clang
%bcond_with openmpi
%bcond_without ffmpeg
%bcond_with opencascade

Name:           netgen
Version:        6.2.1810
Release:        0
Summary:        Automatic 3D tetrahedral mesh generator
License:        LGPL-2.1-only
Group:          Productivity/Graphics/CAD
Source0:        netgen-%{version}.tar.xz
Patch0:         fix_build.patch
# PATCH-FIX-OPENSUSE -- do not try to include immintrin.h when SSE is not supported
Patch1:         0001-Allow-compilation-on-archs-beyond-x86.patch
# not supported by upstream
%if %{with opencascade}
BuildRequires:  occt-devel
BuildRequires:  cmake
BuildRequires:  fdupes
BuildRequires:  pkgconfig(gl)
BuildRequires:  pkgconfig(glu)
BuildRequires:  pkgconfig(icu-uc)
BuildRequires:  pkgconfig(libpcre)
BuildRequires:  pkgconfig(tcl)
BuildRequires:  pkgconfig(tk)
BuildRequires:  pkgconfig(x11)
BuildRequires:  pkgconfig(xmu)
BuildRequires:  pkgconfig(zlib)
BuildRequires:  libjpeg-devel
BuildRequires:  python3-devel
%if %{with openmpi}
BuildRequires:  openmpi-devel
BuildRequires:  metis-devel
%if %{with ffmpeg}
BuildRequires:  pkgconfig(libavcodec)
BuildRequires:  pkgconfig(libavformat) 
BuildRequires:  pkgconfig(libavutil)
BuildRequires:  pkgconfig(libswscale)
%if %{with need_clang}
BuildRequires:  llvm-clang
BuildRequires:  llvm
%if %{?suse_version} == 1315
BuildRequires:  gcc7-c++
BuildRequires:  gcc-c++ >= 7
BuildRequires:  xz

NETGEN is an automatic 3D tetrahedral mesh generator. It accepts
input from constructive solid geometry (CSG) or boundary
representation (BRep) from STL file format. The connection to a
geometry kernel allows the handling of IGES and STEP files. NETGEN
contains modules for mesh optimization and hierarchical mesh

%package devel
Summary:        Development files for netgen
Group:          Development/Libraries/C and C++
Requires:       %{name} = %{version}
%if %{with opencascade}
Requires:       occt-devel

%description devel
Development files for NETGEN.

%setup -q
%patch0 -p1
%patch1 -p1
# fix version, non-number will break FreeCAD macros
sed -i -e 's,"6.2-dev","6.2.0",' libsrc/include/mydefs.hpp

%if %{?suse_version} == 1315
export CC=gcc-7
export CXX=g++-7
mkdir build
cd build
%if %{with need_clang}
    OPTFLAGS="$(echo %{optflags} | sed "s:-grecord-gcc-switches::g") -flto"
  CFLAGS="$OPTFLAGS -fno-strict-aliasing" \
  CXXFLAGS="$OPTFLAGS -fno-strict-aliasing" \
  cmake \
    -DCMAKE_INSTALL_PREFIX=%{_prefix} \
    -DNG_INSTALL_DIR_INCLUDE=%{_includedir}/netgen \
    -DNG_INSTALL_DIR_LIB=%{_libdir}/netgen \
%if %{with need_clang}
    -DCMAKE_C_COMPILER=clang \
    -DCMAKE_CXX_COMPILER=clang++ \
    -DCMAKE_AR=%{_bindir}/llvm-ar \
    -DCMAKE_RANLIB=%{_bindir}/llvm-ranlib \
    -DCMAKE_NM=%{_bindir}/llvm-nm \
    -DCMAKE_OBJDUMP=%{_bindir}/llvm-objdump \
    -DUSE_GUI=ON \
%if %{with openmpi}
    -DUSE_MPI=ON \
    -DUSE_OCC=%{?with_opencascade:ON}%{!?with_opencascade:OFF} \
%if %{with ffmpeg}
  make %{?_smp_mflags}
cd ..

cd build
cd ..
%fdupes %{buildroot}/%{_prefix}

%license LICENSE

%files devel
%dir %{_prefix}/lib/cmake