File geant4.spec of Package geant4

#
# spec file for package geant4
#
# Copyright (c) 2024 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 https://bugs.opensuse.org/
#


%define maj_version 11.3
%bcond_without system_ptl
%if 0%{?suse_version} < 1600
# g++ with c++17 <filesystem> support is required
%define gcc_ver 8
%endif
Name:           geant4
Version:        %{maj_version}.2
Release:        0
Summary:        Toolkit for the simulation of the passage of particles through matter
#Geant4 Software License
License:        BSD-4-Clause
URL:            http://geant4.cern.ch/
Source0:        http://geant4-data.web.cern.ch/releases/%{name}-v%{version}.tar.gz
BuildRequires:  HepMC-devel
BuildRequires:  cmake >= 3.16
BuildRequires:  fdupes
BuildRequires:  gcc%{?gcc_ver}-c++
BuildRequires:  geant4-rpm-macros = %{maj_version}
BuildRequires:  pkgconfig
BuildRequires:  pkgconfig(Qt63DCore)
BuildRequires:  pkgconfig(Qt63DExtras)
BuildRequires:  pkgconfig(Qt63DRender)
BuildRequires:  pkgconfig(Qt6Core)
BuildRequires:  pkgconfig(Qt6Gui)
BuildRequires:  pkgconfig(Qt6OpenGL)
BuildRequires:  pkgconfig(Qt6OpenGLWidgets)
BuildRequires:  pkgconfig(Qt6Widgets)
BuildRequires:  pkgconfig(clhep) >= 2.4.5.1
BuildRequires:  pkgconfig(expat)
BuildRequires:  pkgconfig(freetype2)
BuildRequires:  pkgconfig(glu)
BuildRequires:  pkgconfig(xcb-proto)
BuildRequires:  pkgconfig(xerces-c)
BuildRequires:  pkgconfig(xmu)
BuildRequires:  pkgconfig(zlib)
%if %{with system_ptl}
BuildRequires:  pkgconfig(ptl) >= 2.0
%endif

%description
Geant4 is a toolkit for the simulation of the passage of particles
through matter. Its areas of application include high energy, nuclear
and accelerator physics, as well as studies in medical and space
science. The two main reference papers for Geant4 are published in
Nuclear Instruments and Methods in Physics Research A 506 (2003)
250-303, and IEEE Transactions on Nuclear Science 53 No. 1 (2006)
270-278.

%package libs
Summary:        Shared library for geant4
# G4analysis embeds Roboto and Lato fonts
License:        BSD-4-Clause AND Apache-2.0 AND OFL-1.1

%description libs
This package provides the shared libraries for Geant4 - a toolkit for the
simulation of the passage of particles through matter.

%package devel
Summary:        Headers and other files necessary for development with geant4
# Usual License + Roboto font under Apache-2.0 + Lato fonts under OFL-1.1
License:        BSD-4-Clause AND Apache-2.0 AND OFL-1.1
Requires:       %{name}-libs = %{version}
Requires:       geant4-data-G4ENSDFSTATE
Requires:       geant4-rpm-macros = %{maj_version}
Requires:       pkgconfig(clhep) >= 2.4.5.1
Requires:       pkgconfig(expat)
Requires:       pkgconfig(freetype2)
Requires:       pkgconfig(xmu)
%if %{with system_ptl}
Requires:       pkgconfig(ptl)
%endif

%description devel
This package provides header files and other files necessary for writing
software using Geant4 - a toolkit for the simulation of the passage of
particles through matter

%package examples
Summary:        Examples for Geant4
License:        BSD-4-Clause
BuildArch:      noarch

%description examples
This package provides example codes to demonstrate usage of Geant4.

%prep
%setup -q -n %{name}-v%{version}

# FIX EOL ENCODINGS
find examples -name "README" -print -exec sed -i "s/\r$//" {} \;
find examples -name "CMakeLists.txt" -print -exec sed -i "s/\r$//" {} \;
sed -Ei "s/\r$//" \
  examples/advanced/ICRP110_HumanPhantoms/OrganDoses.out \
  examples/advanced/ICRP145_HumanPhantoms/README_general \
  examples/advanced/dna/cellularPhantom/ImageJ/phantom.ijm \
  examples/advanced/dna/moleculardna/phase_space/phase_space.csv \
  examples/advanced/doiPET/analysis.cpp \
  examples/advanced/doiPET/inputParameter.txt \
  examples/advanced/exp_microdosimetry/weight_function.csv \
  examples/advanced/hadrontherapy/experimentalData/proton/BraggPeak/experimental62MeVProtonBraggPeak.out \
  examples/advanced/human_phantom/gdmlData/Female/*.gdml \
  examples/advanced/xray_SiliconPoreOptics/README.txt \
  examples/advanced/xray_SiliconPoreOptics/pores.gdml \
  examples/advanced/xray_TESdetector/pixelpos.txt \
  examples/advanced/xray_TESdetector/xray_TESdetector.gdml \
  examples/advanced/xray_fluorescence/*.dat \
  examples/extended/electromagnetic/TestEm5/hanson/19um-wwols.ascii \
  examples/extended/electromagnetic/TestEm5/hanson/9um-wwols.ascii \
  examples/extended/electromagnetic/TestEm5/references.txt \
  examples/extended/exoticphysics/phonon/*.out-win-MT \
  examples/extended/exoticphysics/saxs/ADXRD.C \
  examples/extended/exoticphysics/saxs/scattAnalysis.C \
  examples/extended/hadronic/FissionFragment/History \
  examples/extended/hadronic/FissionFragment/batch.in \
  examples/extended/medical/dna/neuron/GranuleCell-Nr2.CNG.swc \
  examples/extended/medical/dna/neuron/NeuralNETWORK.dat \
  examples/extended/medical/dna/wholeNuclearDNA/*.dat \
  examples/extended/parameterisations/Par02/Par02FullDetector.gdml \
  examples/extended/persistency/gdml/G01/loop.gdml \
  examples/extended/radioactivedecay/rdecay01/UserData/*-readme \
%{nil}

# These data files need more greedy fixes
sed -i "s/\r/\n/g" \
  examples/advanced/lAr_calorimeter/data-tracks/*.dat \
  examples/advanced/lAr_calorimeter/geom_data/*.dat

find ./ -name .gitignore -delete

%build
%cmake -DCMAKE_C_COMPILER:STRING=gcc%{?gcc_ver:-%{gcc_ver}} \
       -DCMAKE_CXX_COMPILER:STRING=g++%{?gcc_ver:-%{gcc_ver}} \
       -DGEANT4_USE_GDML:BOOL=ON \
       -DGEANT4_USE_QT:BOOL=ON \
       -DGEANT4_USE_QT_QT6:BOOL=ON \
       -DGEANT4_BUILD_MULTITHREADED:BOOL=ON \
       -DGEANT4_USE_FREETYPE:BOOL=ON \
       -DGEANT4_USE_G3TOG4:BOOL=ON \
       -DGEANT4_USE_OPENGL_X11:BOOL=ON \
       -DGEANT4_USE_NETWORKDAWN:BOOL=ON \
       -DGEANT4_USE_NETWORKVRML:BOOL=ON \
       -DGEANT4_USE_RAYTRACER_X11:BOOL=ON \
       -DGEANT4_USE_SYSTEM_CLHEP:BOOL=ON \
       -DGEANT4_USE_SYSTEM_EXPAT:BOOL=ON \
       -DGEANT4_USE_SYSTEM_PTL:BOOL=%{?with_system_ptl:ON}%{!?with_sytem_ptl:OFF}\
       -DGEANT4_USE_SYSTEM_ZLIB:BOOL=ON \
       -DGEANT4_INSTALL_DATADIR:PATH=%{geant4datadir} \
       %{nil}
%cmake_build

%install
%cmake_install

# MOVE EXAMPLES TO DOCDIR
mkdir -p %{buildroot}%{_docdir}/%{name}
mv %{buildroot}%{_datadir}/Geant4/examples %{buildroot}%{_docdir}/%{name}/

# REMOVE HIDDEN OR MAC DOCUMENTATION FILES
find %{buildroot}%{_docdir}/%{name}/examples/ -name *.mac -delete -print
find %{buildroot}%{_docdir}/%{name}/examples/ -name .README.* -delete -print
rm -fr %{buildroot}%{_docdir}/%{name}/examples/.doxygen
find %{buildroot}%{_docdir}/%{name}/examples/extended/medical/dna/ -name ".*" -delete -print

# REMOVE UNUSABLE PROFILE SCRIPTS, NOT NEEDED FOR STANDARD INSTALLATION ANYWAY
rm %{buildroot}/%{_bindir}/%{name}.sh \
   %{buildroot}/%{_bindir}/%{name}.csh

# REMOVE UNNECESSARY ZERO-LENGTH FILES
find %{buildroot}%{_docdir}/geant4/examples/extended -size 0 -delete -print

# g4tools and font licenses are added explicitly
rm -Rf %{buildroot}%{_datadir}/Geant4/tools.license
rm -Rf %{buildroot}%{_datadir}/Geant4/fonts/license_font*

# Remove copies of Roboto and Lato fonts (embedded)
rm -Rf %{buildroot}%{_datadir}/Geant4/fonts

mkdir -p %{buildroot}%{geant4datadir}

%fdupes %{buildroot}%{_docdir}/%{name}

%ldconfig_scriptlets -n %{name}-libs

%files libs
%license LICENSE
%license source/externals/g4tools/tools.license
%license source/externals/g4tools/fonts/license_font_*
%{_libdir}/*.so
%if %{without system_ptl}
%{_libdir}/libG4ptl.so.*
%endif

%files devel
%license LICENSE
%doc ReleaseNotes/ReleaseNotes.%{maj_version}.html
%{_bindir}/geant4-config
%{_includedir}/Geant4/
%{_libdir}/Geant4-%{version}/
%{_libdir}/cmake/Geant4/
%{_datadir}/Geant4/

%files examples
%license LICENSE
%dir %{_docdir}/%{name}
%doc %{_docdir}/%{name}/examples

%changelog
openSUSE Build Service is sponsored by