%bcond_without vtk
%bcond_without python
%bcond_without hdf5
%bcond_without matio
%bcond_with cgal
%bcond_without doc
%bcond_without check
%global commit ee565c437650f11786f336a1f620474d31e64018
%global date 20180323
%global shortcommit %(c=%{commit}; echo ${c:0:7})
%global relsuf rc1
Name: openmeeg
Version: 2.4
Release: 0.2.%{relsuf}%{?dist}
Summary: Low-frequency bio-electromagnetism solving forward problems in the field of EEG and MEG
License: CeCILL-B
URL: http://openmeeg.github.io/
Source0: https://github.com/openmeeg/openmeeg/archive/%{version}-%{relsuf}.tar.gz#/%{name}-%{version}-%{relsuf}.tar.gz
# Do not require lapacke library
Patch0: openmeeg-openblas_libraries.patch
# Set private directory for Python files
Patch1: openmeeg-python_install_destination.patch
%if 0%{?rhel}
BuildRequires: cmake3, epel-rpm-macros
%else
BuildRequires: cmake
%global cmake3 %cmake
%endif
BuildRequires: gcc-c++, git, chrpath
BuildRequires: gnuplot, wget, graphviz
BuildRequires: expat-devel
BuildRequires: openblas-devel
%{?fedora:BuildRequires: gifticlib-devel}
%{?fedora:BuildRequires: nifticlib-devel}
BuildRequires: zlib-devel
%if %{with hdf5}
BuildRequires: hdf5-devel
%endif
%if %{with matio}
BuildRequires: matio-devel
%endif
%if %{with vtk}
BuildRequires: vtk-devel
%endif
%if %{with cgal}
BuildRequires: CGAL-devel
%endif
# CGAL causes 'memory exhausted' error
%global openmeeg_cmake_options \\\
-DCMAKE_BUILD_TYPE=Release \\\
-DUSE_PROGRESSBAR=ON \\\
-DBUILD_DOCUMENTATION:BOOL=ON \\\
-DBUILD_SHARED_LIBS:BOOL=ON \\\
-DBUILD_SHARED_LIBS_OpenMEEG:BOOL=ON \\\
-DBUILD_SHARED_LIBS_matio:BOOL=ON \\\
-DBUILD_SHARED_LIBS_zlib:BOOL=ON \\\
-DCMAKE_SKIP_INSTALL_RPATH:BOOL=YES \\\
-DCMAKE_INSTALL_LIBDIR:PATH=%{_lib} \\\
-DCMAKE_INSTALL_INCLUDEDIR:PATH=include/%{name} \\\
-DBLA_VENDOR=OpenBLAS \\\
-DBLAS_openblas_LIBRARY:FILEPATH=%{_libdir}/libopenblas.so \\\
%if %{with python} \
-DENABLE_PYTHON:BOOL=ON \\\
-DPYTHON_EXECUTABLE:FILEPATH=%{__python2} \\\
%endif \
%if %{with doc} \
-DBUILD_DOCUMENTATION:BOOL=ON \\\
%endif \
%if %{with check} \
-DBUILD_TESTING:BOOL=ON \\\
%endif \
-DBUILD_TOOLS:BOOL=ON \\\
-DENABLE_PACKAGING:BOOL=OFF \\\
-DSKIP_GITHUB_TESTS:BOOL=ON \\\
%if %{with cgal} \
-DUSE_CGAL:BOOL=ON \\\
%endif \
%{?fedora:-DUSE_GIFTI:BOOL=ON} \\\
-DUSE_OMP:BOOL=ON \\\
%if %{with hdf5} \
-DUSE_SYSTEM_hdf5:BOOL=ON \\\
%endif \
%if %{with matio} \
-DUSE_SYSTEM_matio:BOOL=ON \\\
%endif \
%if %{with vtk} \
-DUSE_VTK:BOOL=ON \\\
%endif \
-DUSE_SYSTEM_zlib:BOOL=ON \\\
-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON
%description
The OpenMEEG software is a C++ package for solving the forward
problems of electroencephalography (EEG) and magnetoencephalography (MEG).
%package devel
Summary: Development files for %{name}
Requires: %{name}%{?_isa} = %{version}-%{release}
%description devel
The %{name}-devel package contains libraries and header files for
developing applications that use OpenMEEG.
%if %{with python}
%package -n python2-openmeeg
Summary: OpenMEEG binding for Python2
%{?python_provide:%python_provide python2-%{name}}
BuildRequires: python2-devel
%{?fedora:BuildRequires: python2-numpy}
%{?rhel:BuildRequires: numpy}
BuildRequires: swig
Requires: %{name}%{?_isa} = %{version}-%{release}
%{?fedora:Requires: python2-numpy}
%{?rhel:Requires: numpy}
Requires: swig
%description -n python2-openmeeg
OpenMEEG binding for Python2.
%endif
%if %{with doc}
%package doc
Summary: Documentation files for OpenMEEG
BuildRequires: doxygen
BuildArch: noarch
%description doc
%{summary}.
%endif
%prep
%autosetup -n %{name}-%{version}-%{relsuf} -p1
%build
mkdir -p build && pushd build
export LDFLAGS="%{__global_ldflags} -Wl,--as-needed"
%{cmake3} %{openmeeg_cmake_options} ..
# If built including the documentation, Make's parallel jobs are damaging
%if %{with doc}
make -j1 VERBOSE=1
%else
%make_build VERBOSE=1
%endif
%install
%make_install -C build
%if %{with check}
%check
pushd build
export LD_LIBRARY_PATH=%{buildroot}%{_libdir}/%{name}:%{_libdir}
ctest --force-new-ctest-process --parallel %{?_smp_mflags}
%endif
%ldconfig_scriptlets
%files
%license LICENSE.txt
%{_bindir}/*
%{_libdir}/lib*.so.*
%files devel
#%%{_libdir}/cmake/%%{name}/
%{_libdir}/lib*.so
%{_includedir}/%{name}/
%if %{with python}
%files -n python2-openmeeg
%{python2_sitearch}/%{name}/
%endif
%if %{with doc}
%files doc
%license LICENSE.txt
%exclude %{_docdir}/OpenMEEG/LICENSE.txt
%exclude %{_docdir}/OpenMEEG/README.rst
%{_docdir}/OpenMEEG/
%endif
%changelog
* Fri Apr 06 2018 Antonio Trande <sagitter@fedoraproject.org> - 2.4-0.2.rc1
- Update to 2.4-rc1
* Fri Mar 23 2018 Antonio Trande <sagitter@fedoraproject.org> - 2.4-0.1.20180323gitee565c4
- Initial rpm