File FreeCAD.spec of Package FreeCAD

# spec file for package FreeCAD
# 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

%define x_prefix %{_libdir}/%{name}

%if 0%{?suse_version} > 1500
%bcond_without boost_signals2
%bcond_with    boost_signals2
%bcond_with    smesh_external

Name:           FreeCAD
Version:        0.19.1
Release:        0
Summary:        General Purpose 3D CAD Modeler
License:        LGPL-2.0-or-later AND GPL-2.0-or-later
Group:          Productivity/Graphics/CAD
# PATCH-FIX-OPENSUSE Use correct import for Python 3 tkinter
Patch1:         fix_unittestgui_tkinter_py3.patch
Patch2:         fix-smesh-vtk9.patch

# Test suite fails on 32bit and I don't want to debug that anymore
ExcludeArch:    %ix86 %arm ppc s390 s390x

BuildRequires:  Coin-devel
BuildRequires:  libboost_filesystem-devel >= 1.55
BuildRequires:  libboost_graph-devel >= 1.55
BuildRequires:  libboost_program_options-devel >= 1.55
BuildRequires:  libboost_regex-devel >= 1.55
%if %{without boost_signals2}
BuildRequires:  libboost_signals-devel >= 1.55
BuildRequires:  libboost_serialization-devel >= 1.55
BuildRequires:  libboost_system-devel >= 1.55
BuildRequires:  libboost_thread-devel >= 1.55

BuildRequires:  cmake
BuildRequires:  double-conversion-devel
BuildRequires:  eigen3-devel
BuildRequires:  fdupes
BuildRequires:  glew-devel
BuildRequires:  hdf5-devel
BuildRequires:  hicolor-icon-theme
%if %{with smesh_external}
# We use the internal smesh version with fixes atm
BuildRequires:  smesh-devel
BuildRequires:  java-devel
BuildRequires:  libXerces-c-devel
BuildRequires:  libXi-devel
BuildRequires:  libmed-devel
BuildRequires:  libspnav-devel
BuildRequires:  make
BuildRequires:  netgen-devel
BuildRequires:  occt-devel
BuildRequires:  pkg-config
BuildRequires:  proj-devel
BuildRequires:  sqlite3-devel

# Qt5 & python3
BuildRequires:  python3-devel
BuildRequires:  python3-matplotlib
BuildRequires:  python3-pybind11-devel
BuildRequires:  python3-pycxx-devel
BuildRequires:  python3-pyside2-devel
BuildRequires:  python3-vtk
BuildRequires:  python3-xml
BuildRequires:  pkgconfig(Qt5Concurrent)
BuildRequires:  pkgconfig(Qt5OpenGL)
BuildRequires:  pkgconfig(Qt5PrintSupport)
BuildRequires:  pkgconfig(Qt5ScriptTools)
BuildRequires:  pkgconfig(Qt5Svg)
BuildRequires:  pkgconfig(Qt5UiTools)
BuildRequires:  pkgconfig(Qt5WebKit)
BuildRequires:  pkgconfig(Qt5WebKitWidgets)
BuildRequires:  pkgconfig(Qt5X11Extras)
BuildRequires:  pkgconfig(Qt5XmlPatterns)
Requires:       python3-numpy
Requires:       python3-pyside2
Requires:       python3-vtk
# For Arch & Draft workbench
Requires:       python3-pivy
# For FEM workbench
Requires:       python3-PyYAML
Requires:       python3-ply
Requires:       python3-six

BuildRequires:  swig
BuildRequires:  update-desktop-files
BuildRequires:  vtk-devel
BuildRequires:  zlib-devel
# we need to ensure to have the minimum version from build env
Requires:       libopencascade7 >= %(/bin/bash -c 'rpm -q --qf "%%{version}" libopencascade7')

Recommends:     ccx

Provides:       freecad

FreeCAD is a parametric 3D modeler made primarily to design real-life objects
of any size. Parametric modeling allows modifying designs by
going back into the model history and changing its parameters. FreeCAD is
customizable and scriptable.

%package devel
Summary:        Development Files for %{name}
Group:          Development/Libraries/C and C++
Requires:       %{name} = %{version}

%description devel
This package contains the files needed for development with FreeCAD.

%setup -q
%autopatch -p1

# fix env-script-interpreter
sed -i '1c#!%{__python3}' \
        src/Mod/AddonManager/ \
        src/Mod/Mesh/App/ \
        src/Mod/Robot/ \
        src/Mod/Robot/ \
        src/Mod/Spreadsheet/ \
        src/Mod/TechDraw/TDTest/D* \

# Fix "non-executable-script" rpmlint warning
chmod 755 src/Mod/AddonManager/ \
          src/Mod/Robot/ \
          src/Mod/Robot/ \
          src/Mod/Spreadsheet/ \
          src/Mod/TechDraw/TDTest/D* \

# Fix "wrong-script-end-of-line-encoding" rpmlint warning
sed -i 's/\r$//' src/Mod/Mesh/App/
sed -i 's/\r$//' src/Mod/Part/
sed -i 's/\r$//' src/Mod/PartDesign/Scripts/
sed -i 's/\r$//' src/Mod/PartDesign/Scripts/
sed -i 's/\r$//' src/Mod/PartDesign/Scripts/
sed -i 's/\r$//' src/Mod/Robot/
sed -i 's/\r$//' src/Mod/Robot/
sed -i 's/\r$//' src/Mod/Test/

# Remove 3rd party libs
rm src/3rdparty/Pivy -fr
rm src/3rdparty/Pivy-0.5 -fr

# Resources are looked up relative to the binaries location,
# so all these need the same prefix, see src/App/Application.cpp
%cmake \
  -DCMAKE_INSTALL_PREFIX=%{x_prefix} \
  -DCMAKE_INSTALL_LIBDIR=%{x_prefix}/lib \
  -DCMAKE_INSTALL_BINDIR=%{x_prefix}/bin \
  -DCMAKE_INSTALL_DATADIR=%{_datadir}/%{name} \
  -DCMAKE_INSTALL_DOCDIR=%{_docdir}/%{name} \
  -DCMAKE_INSTALL_INCLUDEDIR=%{_includedir}/%{name} \
  -DOCC_INCLUDE_DIR=%{_includedir}/opencascade \
  -DRESOURCEDIR=%{_datadir}/%{name} \
  -DPYTHON_EXECUTABLE=/usr/bin/python3 \
  -DSHIBOKEN_INCLUDE_DIR=/usr/include/shiboken2/ \
  -DPYSIDE_INCLUDE_DIR=/usr/include/PySide2/ \
  -DFREECAD_USE_EXTERNAL_SMESH=%{?with_smesh_external:ON}%{!?with_smesh_external:OFF} \
  -DBUILD_FEM:BOOL=%{?with_smesh:ON}%{!?with_smesh:OFF} \
  -Wno-dev \



%suse_update_desktop_file -r org.freecadweb.FreeCAD Education Engineering

# Remove unneeded files
find %{buildroot} -type f -name "*.la" -delete -print
rm -Rf %{buildroot}%{_datadir}/pixmaps
# Broken
rm -Rf %{buildroot}%{_datadir}/thumbnailers

# Link binaries
mkdir -p %{buildroot}/usr/bin
ln -s -t %{buildroot}/usr/bin %{x_prefix}/bin/FreeCAD
ln -s -t %{buildroot}/usr/bin %{x_prefix}/bin/FreeCADCmd

%fdupes %{buildroot}/%{_libdir}
%fdupes %{buildroot}/%{_datadir}

%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig

%license LICENSE
%doc %{_docdir}/%{name}/

openSUSE Build Service is sponsored by