File oce.spec of Package oce

# spec file for package oce
# Copyright (c) 2017 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

# Whether clang should be used instead of gcc
%bcond_with scanbuild
%if %{with scanbuild}
%bcond_without clang
%bcond_with clang

# Whether DRAWEXE should be built
%bcond_without build_draw

# disable vtk atm, oce code needs some older version
%if 0%{?suse_version} > 91310
%bcond_without build_vtk
%bcond_with build_vtk

# Define openCASCADE version
%define ocversion 6.9.1

Name:           oce
Version:        0.18.1
Release:        0
Summary:        OpenCASCADE Community Edition
License:        LGPL-2.1 WITH OCCT-exception-1.0
Group:          Productivity/Graphics/CAD

Source0:        oce-%{version}.tar.xz
# PATCH-FIX-UPSTREAM oce-check-for-xlocale.patch -- Implement a check for xlocale.h header in CMakeLists.txt to define HAVE_XLOCALE_H instead of macro-level checks based on OS; fixes build failures with glibc >= 2.26 where xlocale.h is no longer available.
Patch0:         oce-check-for-xlocale.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

BuildRequires:  cmake
BuildRequires:  fdupes
%if %{with clang}
BuildRequires:  libstdc++-devel
BuildRequires:  llvm-clang
BuildRequires:  gcc-c++
BuildRequires:  ftgl-devel
BuildRequires:  pkgconfig(freetype2)
BuildRequires:  pkgconfig(gl)
BuildRequires:  pkgconfig(glu)
BuildRequires:  pkgconfig(python)
%if %{with build_draw}
%if 0%{?suse_version} > 1230
BuildRequires:  pkgconfig(tcl)
BuildRequires:  pkgconfig(tk)
BuildRequires:  tcl-devel
BuildRequires:  tk-devel
BuildRequires:  xz
BuildRequires:  pkgconfig(x11)
BuildRequires:  pkgconfig(xext)
%if %{with build_vtk}
BuildRequires:  vtk-devel
%ifarch x86_64

%if 0%{?suse_version} > 1310
BuildRequires:  java-devel
Provides:       OCE = %{version}
Provides:       OpenCASCADE = %{ocversion}
Obsoletes:      OCE < %{version}
Obsoletes:      OpenCASCADE < %{ocversion}
Conflicts:      otherproviders(OpenCASCADE)

OpenCASCADE is a suite for 3D surface and solid modeling, visualization, data
exchange and rapid application development. It is a platform for
development of numerical simulation software including CAD/CAM/CAE, AEC and
GIS, as well as PDM applications.

%package vtk
Summary:        VTK libraries
Group:          System/Libraries

%description vtk
This package includes OpenCASCADE VTK libraries.

%package DRAWEXE
Summary:        Scripting interface to the OpenCASCADE libraries
Group:          Productivity/Graphics/Visualization/Other

%description DRAWEXE
This program provides a kind of scripting interface to the OpenCASCADE
libraries. You can perform a simple test by starting it and entering at the
command line: "pload ALL" then "source /usr/share/oce/src/DrawResources/VisualizationDemo.tcl".

%package devel
Summary:        Development files for openCASCADE
Group:          Development/Libraries/C and C++
Requires:       %{name} = %{version}
%if %{with build_vtk}
Requires:       %{name}-vtk = %{version}
Provides:       OCE-devel = %{version}
Provides:       OpenCASCADE-devel = %{ocversion}
Obsoletes:      OCE-devel < %{version}
Obsoletes:      OpenCASCADE-devel < %{ocversion}
Conflicts:      otherproviders(OpenCASCADE-devel)

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

%setup -q
%patch0 -p1

mkdir build
cd build
  CFLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing" \
  CXXFLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing" \
%if %{with clang}
%if %{with scanbuild}
  CC=/usr/share/clang/scan-build/ccc-analyzer CXX=/usr/share/clang/scan-build/c++-analyzer CCC_CXX=clang++ \
  CC=clang CXX=clang++ \
  cmake \
%if %{with build_vtk}
%if %{with build_draw}
    -DOCE_INSTALL_PREFIX=%_prefix \
    -DOCE_INSTALL_BIN_DIR=%_bindir \
    -DOCE_INSTALL_LIB_DIR=%_libdir \
    -DOCE_INSTALL_INCLUDE_DIR=%_includedir/oce \
    -DOCE_INSTALL_DATA_DIR=%_datadir/oce \
    -DOCE_INSTALL_CMAKE_DATA_DIR=%_datadir/oce \
%if %{with scanbuild}
  /usr/share/clang/scan-build/scan-build --use-analyzer %_bindir/clang -analyze-headers \
  make %{?_smp_mflags} VERBOSE=1
cd ..

cd build
  make install DESTDIR=%buildroot
cd ..

%fdupes -s %buildroot/%_includedir

%post -p /sbin/ldconfig

%postun -p /sbin/ldconfig

%post vtk -p /sbin/ldconfig

%postun vtk -p /sbin/ldconfig

%if %{with build_vtk}
%exclude %_libdir/*Vtk*.so.*
%exclude %_libdir/*.so
%if %{with build_draw}
%exclude %_datadir/oce/src/DrawResources
%exclude %_datadir/oce/*.cmake

%files DRAWEXE

%if %{with build_vtk}
%files vtk

%files devel

openSUSE Build Service is sponsored by