-%define boost_version 1.32
+# TODO
+# - optflags
+# - move qt stuff to subpackages?
+#
+# Conditional build:
+%bcond_with examples # demo+examples build
+%bcond_with qt3 # CGAL_Qt3 library
+
+%define boost_ver 1.48
+%define qt5_ver 5.3
Summary: Computational Geometry Algorithms Library
+Summary(pl.UTF-8): Computational Geometry Algorithms Library - biblioteka algorytmów geometrii obliczeniowej
Name: CGAL
-Version: 3.3.1
-Release: 1
-License: QPL and LGPLv2 and LGPLv2+
+Version: 4.7
+Release: 4
+License: GPL v3+ and LGPL v3+
Group: Libraries
+Source0: https://github.com/CGAL/releases/archive/%{name}-%{version}.tar.gz
+# Source0-md5: 50b29d3f3372cd93aaa31d01f0e45036
URL: http://www.cgal.org/
-Source0: ftp://ftp.mpi-sb.mpg.de/pub/outgoing/CGAL/%{name}-%{version}.tar.gz
-# Source0-md5: 733339b6b05b48d4c7934a6e735b6fc0
-Patch1: %{name}-install_cgal-SUPPORT_REQUIRED.patch
-Patch2: %{name}-build-library.patch
-Patch4: %{name}-install_cgal-no_versions_in_compiler_config.h.patch
-BuildRequires: blas-devel
-BuildRequires: boost-devel >= %{boost_version}
-BuildRequires: gmp-c++-devel
-BuildRequires: gmp-devel
-BuildRequires: lapack-devel
-BuildRequires: mpfr-devel
-BuildRequires: qt-devel >= 3.0
+BuildRequires: OpenGL-GLU-devel
+BuildRequires: Qt5Core-devel >= %{qt5_ver}
+BuildRequires: Qt5Gui-devel >= %{qt5_ver}
+BuildRequires: Qt5OpenGL-devel >= %{qt5_ver}
+BuildRequires: Qt5Svg-devel >= %{qt5_ver}
+BuildRequires: Qt5Widgets-devel >= %{qt5_ver}
+BuildRequires: boost-devel >= %{boost_ver}
+BuildRequires: cmake >= 2.8.11
+BuildRequires: gmp-devel >= 4.1.4
+BuildRequires: libstdc++-devel
+BuildRequires: mpfr-devel >= 2.2.1
+BuildRequires: qt5-build >= %{qt5_ver}
+BuildRequires: qt5-qmake >= %{qt5_ver}
BuildRequires: sed >= 4.0
BuildRequires: zlib-devel
+%if %{with qt3}
+BuildRequires: qt-devel >= 3
+BuildRequires: xorg-lib-libX11-devel
+BuildRequires: xorg-lib-libXext-devel
+%endif
+%if %{with examples}
+BuildRequires: blas-devel
+BuildRequires: eigen3 >= 3.1.91
+BuildRequires: gmp-c++-devel >= 4.1.4
+BuildRequires: lapack-devel
+BuildRequires: tbb
+#TODO: mpfi QGLViewer ipelib
+%endif
BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
%description
The goal is to provide easy access to useful, reliable geometric
algorithms.
+%description -l pl.UTF-8
+Biblioteka dla aplikacji CGAL (Computational Geometry Algorithms
+Library). CGAL to wspólny projekt kilku placówek w Europie i Izraelu.
+Celem jest udostępnienie najważniejszych rozwiązań i metod powstałych
+w geometrii obliczeniowej dla użytkowników przemysłowych i naukowych w
+postaci biblioteki C++. Ma ona za zadanie zapewniać łatwy dostęp do
+przydatnych, wiarygodnych algorytmów geometrycznych.
+
%package devel
Summary: Development files and tools for CGAL applications
+Summary(pl.UTF-8): Pliki i narzędzia programistyczne dla aplikacji CGAL
Group: Development/Libraries
-Requires: %{_sysconfdir}/profile.d
Requires: %{name} = %{version}-%{release}
+Requires: boost-devel >= %{boost_ver}
+Requires: libstdc++-devel
+# for Qt5 component
+Requires: Qt5Core-devel >= %{qt5_ver}
+Requires: Qt5Gui-devel >= %{qt5_ver}
+Requires: Qt5OpenGL-devel >= %{qt5_ver}
+Requires: Qt5Widgets-devel >= %{qt5_ver}
+# for Qt3 component
+%if %{with qt3}
+Requires: qt-devel >= 3
+%endif
+# CGAL header interfaces for (using their headers) - use Suggests?
+Requires: gmp-c++-devel >= 4.1.4
+Requires: gmp-devel >= 4.1.4
+Requires: mpfr-devel >= 2.2.1
+#Suggests: eigen3 >= 3.1 gsl-devel tbb-devel vtk-devel
+#Suggests(TODO): <rs_exports.h> <rs3_fncts.h> <taucs.h> <OpenMesh/Core/Mesh/PolyMesh_ArrayKernelT.hh> <NTL/ZZX.h> <mpfi.h> <LEDA/*.h> <ipelib.h>
+Requires: zlib-devel
+# CGAL header interfaces for (without using their headers) - use Suggests?
Requires: blas-devel
-Requires: boost-devel >= %{boost_version}
-Requires: gmp-c++-devel
-Requires: gmp-devel
Requires: lapack-devel
-Requires: mpfr-devel
-Requires: qt-devel
-Requires: zlib-devel
%description devel
-The %{name}-devel package provides the headers files and tools you may
-need to develop applications using CGAL.
+This package provides the header files and tools you may need to
+develop applications using CGAL.
+
+%description devel -l pl.UTF-8
+Ten pakiet zawiera pliki nagłówkowe i narzędzia potrzebne do tworzenia
+aplikacji wykorzystujących CGAL.
%package demos-source
Summary: Examples and demos of CGAL algorithms
+Summary(pl.UTF-8): Przykłady i programy demonstracyjne do algorytmów CGAL
Group: Documentation
Requires: %{name}-devel = %{version}-%{release}
%description demos-source
-The %{name}-demos-source package provides the sources of examples and
-demos of CGAL algorithms.
+This package provides the sources of examples and demos of CGAL
+algorithms.
+%description demos-source -l pl.UTF-8
+Ten pakiet zawiera kod źrodłowy programów przykładowych i
+demonstracyjnych do algorytmów CGAL.
%prep
-%setup -q
-%patch1 -p0 -b .support-required.bak
-%patch2 -p1 -b .build-library.bak
-%patch4 -p1 -b .no_versions.bak
-
-chmod a-x examples/Nef_3/handling_double_coordinates.cin
-# fix end-of-lines of several files
-for f in demo/Straight_skeleton_2/data/vertex_event_9.poly \
- demo/Straight_skeleton_2/data/vertex_event_0.poly \
- examples/Surface_mesh_parameterization/data/mask_cone.off \
- examples/Boolean_set_operations_2/test.dxf; do
- if [ -r $f ]; then
- sed -i -e 's/\r//' $f
- fi
-done
+%setup -q -n releases-%{name}-%{version}
%build
-export QTDIR=%{_prefix}
-./install_cgal -ni g++ --CUSTOM_CXXFLAGS "$RPM_OPT_FLAGS" \
- --without-autofind \
- --with-ZLIB \
- --with-BOOST \
- --with-BOOST_PROGRAM_OPTIONS \
- --with-X11 \
- --with-GMP \
- --with-GMPXX \
- --with-MPFR \
- --with-QT3MT \
- --with-REFBLASSHARED \
- --with-DEFAULTLAPACK \
- --with-OPENGL \
- --QT_INCL_DIR=%{_includedir}/qt \
- --QT_LIB_DIR=%{_libdir} \
- --disable-static
-
+install -d build
+cd build
+# override build type, because:
+# PLD is not a valid build type: only Release or Debug is allowed
+%cmake .. \
+ -DCMAKE_BUILD_TYPE=%{!?debug:Release}%{?debug:Debug} \
+ -DCMAKE_CXX_FLAGS_Release="%{rpmcxxflags}" \
+ -DCMAKE_EXE_LINKER_FLAGS_Release="%{rpmldflags}" \
+ -DCMAKE_SHARED_LINKER_FLAGS_Release="%{rpmldflags}" \
+ -DCGAL_INSTALL_LIB_DIR=%{_lib} \
+ -DCGAL_INSTALL_DOC_DIR= \
+ %{?with_qt3:-DWITH_CGAL_Qt3=ON} \
+%if %{with examples}
+ -DWITH_demos=ON \
+ -DWITH_examples=ON
+%endif
+
+%{__make}
%install
rm -rf $RPM_BUILD_ROOT
-case "%{_arch}" in
-*64* | s390)
- SUFFIX=64 ;;
-*)
- SUFFIX=32 ;;
-esac
-
-# Install headers
-install -d $RPM_BUILD_ROOT%{_includedir}
-cp -a include/* $RPM_BUILD_ROOT%{_includedir}
-rm -rf $RPM_BUILD_ROOT%{_includedir}/CGAL/config/msvc*
-mv $RPM_BUILD_ROOT%{_includedir}/CGAL/config/*/CGAL/compiler_config.h $RPM_BUILD_ROOT%{_includedir}/CGAL/compiler_config.h
-
-# remove the arch-specific comment
-%{__sed} -i -e '/System: / d' $RPM_BUILD_ROOT%{_includedir}/CGAL/compiler_config.h
-
-# use the timestamp of install_cgal
-touch -r install_cgal $RPM_BUILD_ROOT%{_includedir}/CGAL/compiler_config.h
-rm -rf $RPM_BUILD_ROOT%{_includedir}/CGAL/config
-
-# Install scripts (only those prefixed with "cgal_").
-install -d $RPM_BUILD_ROOT%{_bindir}
-install -p scripts/cgal_* $RPM_BUILD_ROOT%{_bindir}
-
-# Install libraries
-install -d $RPM_BUILD_ROOT%{_libdir}
-cp -a lib/*/lib* $RPM_BUILD_ROOT%{_libdir}
-
-# Install makefile:
-install -d $RPM_BUILD_ROOT%{_datadir}/CGAL
-touch -r make $RPM_BUILD_ROOT%{_datadir}/CGAL
-install -p make/makefile_* $RPM_BUILD_ROOT%{_datadir}/CGAL/cgal-${SUFFIX}.mk
-
-# Install demos and examples
-install -d $RPM_BUILD_ROOT%{_datadir}/CGAL/
-touch -r demo $RPM_BUILD_ROOT%{_datadir}/CGAL/
-cp -a demo $RPM_BUILD_ROOT%{_datadir}/CGAL/demo
-cp -a examples $RPM_BUILD_ROOT%{_datadir}/CGAL/examples
-
-# Modify makefile
-cat > makefile.sed <<'EOF'
-s,CGAL_INCL_DIR *=.*,CGAL_INCL_DIR = %{_includedir},;
-s,CGAL_LIB_DIR *=.*,CGAL_LIB_DIR = %{_libdir},;
-/CUSTOM_CXXFLAGS/ s/-O2 //;
-/CUSTOM_CXXFLAGS/ s/-g //;
-/CGAL_INCL_DIR/ s,/CGAL/config/.*,,;
-s,/$(CGAL_OS_COMPILER),,g;
-/-I.*CGAL_INCL_CONF_DIR/ d
-EOF
-
-# use -i.bak to generate cgal-${SUFFIX}.mk.bak with right timestamp
-# used below to restore the timestamp
-sed -i.bak -f makefile.sed $RPM_BUILD_ROOT%{_datadir}/CGAL/cgal-${SUFFIX}.mk
-
-# check if the sed script above has worked:
-grep -q %{_builddir} $RPM_BUILD_ROOT%{_datadir}/CGAL/cgal-${SUFFIX}.mk && false
-grep -q $RPM_BUILD_ROOT $RPM_BUILD_ROOT%{_datadir}/CGAL/cgal-${SUFFIX}.mk && false
-grep -q CGAL/config $RPM_BUILD_ROOT%{_datadir}/CGAL/cgal-${SUFFIX}.mk && false
-grep -q -E 'CUSTOM_CXXFLAGS.*(-O2|-g )' $RPM_BUILD_ROOT%{_datadir}/CGAL/cgal-${SUFFIX}.mk && false
-
-# Remove -L and -R flags from the makefile
-cat > makefile-noprefix.sed <<'EOF'
-/'-L$(CGAL_LIB_DIR)'/ d;
-/-R$(CGAL_LIB_DIR)/ d;
-/'-I$(CGAL_INCL_DIR)'/ d;
-EOF
-
-sed -i -f makefile-noprefix.sed $RPM_BUILD_ROOT%{_datadir}/CGAL/cgal-${SUFFIX}.mk
-
-# restore the timestamp and remove the .bak file
-touch -r $RPM_BUILD_ROOT%{_datadir}/CGAL/cgal-${SUFFIX}.mk.bak $RPM_BUILD_ROOT%{_datadir}/CGAL/cgal-${SUFFIX}.mk
-rm -f $RPM_BUILD_ROOT%{_datadir}/CGAL/cgal-${SUFFIX}.mk.bak
-
-# check that the sed script has worked
-grep -q -E -- '-[LI]\$' $RPM_BUILD_ROOT%{_datadir}/CGAL/cgal-${SUFFIX}.mk && false
-grep -q -E -- '-R' $RPM_BUILD_ROOT%{_datadir}/CGAL/cgal-${SUFFIX}.mk && false
-
-# Create %{_sysconfdir}/profile.d/ scripts
-install -d $RPM_BUILD_ROOT%{_sysconfdir}/profile.d
-cat > $RPM_BUILD_ROOT%{_sysconfdir}/profile.d/cgal.sh <<EOF
-ARCH=`uname -m`
-
-case \$ARCH in
- x86_64|ia64|s390)
- SUFFIX=64 ;;
- *)
- SUFFIX=32 ;;
-esac
-
-if [ -z "\$CGAL_MAKEFILE" ] ; then
- CGAL_MAKEFILE="%{_datadir}/CGAL/cgal-${SUFFIX}.mk"
- export CGAL_MAKEFILE
-fi
-EOF
-
-cat > $RPM_BUILD_ROOT%{_sysconfdir}/profile.d/cgal.csh <<EOF
-set ARCH=`uname -m`
-
-switch (\$ARCH)
-case x86_64:
-case ia64:
-case s390:
- set SUFFIX=64;
- breaksw;
-default:
- set SUFFIX=62;
-endsw
-
-if (! \$?CGAL_MAKEFILE ) then
- setenv CGAL_MAKEFILE "%{_datadir}/CGAL/cgal-${SUFFIX}.mk"
-endif
-EOF
-
-# use the timestamp of install_cgal
-touch -r install_cgal $RPM_BUILD_ROOT%{_sysconfdir}/profile.d/cgal.*sh
+%{__make} -C build install \
+ DESTDIR=$RPM_BUILD_ROOT
+
+# useless in binary package
+%{__rm} $RPM_BUILD_ROOT%{_bindir}/{cgal_create_CMakeLists,cgal_create_cmake_script,cgal_make_macosx_app}
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(644,root,root,755)
-%doc AUTHORS LICENSE LICENSE.FREE_USE LICENSE.LGPL LICENSE.QPL CHANGES
-%attr(755,root,root) %{_libdir}/libCGAL*.so.*.*.*
-%attr(755,root,root) %ghost %{_libdir}/libCGAL*.so.2
+%doc AUTHORS CHANGES LICENSE LICENSE.BSL LICENSE.FREE_USE LICENSE.LGPL
+%attr(755,root,root) %{_libdir}/libCGAL.so.*.*.*
+%attr(755,root,root) %ghost %{_libdir}/libCGAL.so.11
+%attr(755,root,root) %{_libdir}/libCGAL_Core.so.*.*.*
+%attr(755,root,root) %ghost %{_libdir}/libCGAL_Core.so.11
+%attr(755,root,root) %{_libdir}/libCGAL_ImageIO.so.*.*.*
+%attr(755,root,root) %ghost %{_libdir}/libCGAL_ImageIO.so.11
+%if %{with qt3}
+%attr(755,root,root) %{_libdir}/libCGAL_Qt3.so.*.*.*
+%attr(755,root,root) %ghost %{_libdir}/libCGAL_Qt3.so.11
+%endif
+%attr(755,root,root) %{_libdir}/libCGAL_Qt5.so.*.*.*
+%attr(755,root,root) %ghost %{_libdir}/libCGAL_Qt5.so.11
%files devel
%defattr(644,root,root,755)
+%attr(755,root,root) %{_libdir}/libCGAL.so
+%attr(755,root,root) %{_libdir}/libCGAL_Core.so
+%attr(755,root,root) %{_libdir}/libCGAL_ImageIO.so
+%if %{with qt3}
+%attr(755,root,root) %{_libdir}/libCGAL_Qt3.so
+%endif
+%attr(755,root,root) %{_libdir}/libCGAL_Qt5.so
%{_includedir}/CGAL
-%{_libdir}/libCGAL*.so
-%dir %{_datadir}/CGAL
-%{_datadir}/CGAL/cgal*.mk
-%attr(755,root,root) %{_bindir}/*
-%exclude %{_bindir}/cgal_make_macosx_app
-%config(noreplace,missingok) %verify(not md5 mtime size) %attr(755,root,root) /etc/profile.d/cgal.*
-
-%files demos-source
-%defattr(644,root,root,755)
-%{_datadir}/CGAL/demo
-%{_datadir}/CGAL/examples
-%exclude %{_datadir}/CGAL/*/*/*.vcproj
-%exclude %{_datadir}/CGAL/*/*/skip_vcproj_auto_generation
+%{_libdir}/CGAL
+%{_mandir}/man1/cgal_create_cmake_script.1*