commit:     c2e5356f22ed66e85c47d746b3abd974eb605e78
Author:     Alexander Puck Neuwirth <apn-pucky <AT> gentoo <DOT> org>
AuthorDate: Thu Jan 22 10:47:16 2026 +0000
Commit:     Alexander Puck Neuwirth <apn-pucky <AT> gentoo <DOT> org>
CommitDate: Fri Feb  6 14:42:25 2026 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c2e5356f

sci-physics/hepmc: cmake4 patches

Closes: https://bugs.gentoo.org/968135
Part-of: https://github.com/gentoo/gentoo/pull/45488
Closes: https://github.com/gentoo/gentoo/pull/45488
Signed-off-by: Alexander Puck Neuwirth <apn-pucky <AT> gentoo.org>

 sci-physics/hepmc/files/hepmc-2.06.11-cmake4.patch |  31 ++++++
 .../hepmc/files/hepmc-2.06.11-cmp0153.patch        |  49 ++++++++++
 sci-physics/hepmc/hepmc-2.06.11-r1.ebuild          | 104 +++++++++++++++++++++
 3 files changed, 184 insertions(+)

diff --git a/sci-physics/hepmc/files/hepmc-2.06.11-cmake4.patch 
b/sci-physics/hepmc/files/hepmc-2.06.11-cmake4.patch
new file mode 100644
index 000000000000..7624d30cf64e
--- /dev/null
+++ b/sci-physics/hepmc/files/hepmc-2.06.11-cmake4.patch
@@ -0,0 +1,31 @@
+https://gitlab.cern.ch/hepmc/HepMC/-/merge_requests/16
+From 1bb90ccda81187c71c1e234e3d55390684ce1041 Mon Sep 17 00:00:00 2001
+From: Giulio Eulisse <[email protected]>
+Date: Tue, 6 Jan 2026 13:39:58 +0100
+Subject: [PATCH] Add support for CMake 4
+
+Upstream deprecated support for CMake <= 3.5.
+
+See 
https://cmake.org/cmake/help/latest/release/4.0.html#deprecated-and-removed-features
+---
+ CMakeLists.txt | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 7b2dd93..6d7e807 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -13,8 +13,8 @@
+ # which matches the default HepMC autoconf flags
+ 
#------------------------------------------------------------------------------
+ 
+-# use cmake 2.6 or later
+-cmake_minimum_required (VERSION 2.6)
++# use cmake 3.16 or later
++cmake_minimum_required (VERSION 3.16)
+
+ # project name and version
+ project(HepMC)
+-- 
+GitLab
+

diff --git a/sci-physics/hepmc/files/hepmc-2.06.11-cmp0153.patch 
b/sci-physics/hepmc/files/hepmc-2.06.11-cmp0153.patch
new file mode 100644
index 000000000000..cd4949d498bb
--- /dev/null
+++ b/sci-physics/hepmc/files/hepmc-2.06.11-cmp0153.patch
@@ -0,0 +1,49 @@
+https://gitlab.cern.ch/hepmc/HepMC/-/merge_requests/17
+From 3b1f6ebfa2af3e56013c8f9f771baa978bfe426d Mon Sep 17 00:00:00 2001
+From: Alexander Puck Neuwirth <[email protected]>
+Date: Thu, 22 Jan 2026 11:26:12 +0100
+Subject: [PATCH] fix: Policy CMP0153: The exec_program command should not be
+ called.
+
+---
+ cmake/Modules/HepMCUseCpack.cmake  | 5 +++--
+ cmake/Modules/HepMCVariables.cmake | 5 +++--
+ 2 files changed, 6 insertions(+), 4 deletions(-)
+
+diff --git a/cmake/Modules/HepMCUseCpack.cmake 
b/cmake/Modules/HepMCUseCpack.cmake
+index 49040b7..298cff0 100644
+--- a/cmake/Modules/HepMCUseCpack.cmake
++++ b/cmake/Modules/HepMCUseCpack.cmake
+@@ -8,9 +8,10 @@
+ #
+ FUNCTION(_My_COMPILER_DUMPVERSION _OUTPUT_VERSION)
+ 
+-  EXEC_PROGRAM(${CMAKE_CXX_COMPILER}
+-    ARGS ${CMAKE_CXX_COMPILER_ARG1} -dumpversion
++  execute_process(
++    COMMAND ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} -dumpversion
+     OUTPUT_VARIABLE _my_COMPILER_VERSION
++    OUTPUT_STRIP_TRAILING_WHITESPACE
+   )
+   set( COMPILER_VERSION ${_my_COMPILER_VERSION} PARENT_SCOPE)
+   STRING(REGEX REPLACE "([0-9])\\.([0-9])(\\.[0-9])?" "\\1\\2"
+diff --git a/cmake/Modules/HepMCVariables.cmake 
b/cmake/Modules/HepMCVariables.cmake
+index bd8b713..475310b 100644
+--- a/cmake/Modules/HepMCVariables.cmake
++++ b/cmake/Modules/HepMCVariables.cmake
+@@ -10,9 +10,10 @@
+ # so we need this for the example makefile
+ macro( _hepmc_fortran_compiler )
+ 
+-  EXEC_PROGRAM(${CMAKE_CXX_COMPILER}
+-    ARGS ${CMAKE_CXX_COMPILER_ARG1} -dumpversion
++  execute_process(
++    COMMAND ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} -dumpversion
+     OUTPUT_VARIABLE _my_COMPILER_VERSION
++    OUTPUT_STRIP_TRAILING_WHITESPACE
+   )
+   STRING(REGEX REPLACE "([0-9])\\.([0-9])(\\.[0-9])?" "\\1"
+     _my_COMPILER_BASE_VERSION ${_my_COMPILER_VERSION})
+-- 
+GitLab
+

diff --git a/sci-physics/hepmc/hepmc-2.06.11-r1.ebuild 
b/sci-physics/hepmc/hepmc-2.06.11-r1.ebuild
new file mode 100644
index 000000000000..22110e6cf53d
--- /dev/null
+++ b/sci-physics/hepmc/hepmc-2.06.11-r1.ebuild
@@ -0,0 +1,104 @@
+# Copyright 1999-2026 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+inherit cmake flag-o-matic
+
+MYP=HepMC-${PV}
+
+DESCRIPTION="Event Record for Monte Carlo Generators"
+HOMEPAGE="
+       https://hepmc.web.cern.ch/hepmc/
+       https://gitlab.cern.ch/hepmc/HepMC/
+"
+SRC_URI="https://hepmc.web.cern.ch/hepmc/releases/hepmc${PV}.tgz";
+S="${WORKDIR}/${MYP}"
+
+LICENSE="GPL-2"
+SLOT="2"
+KEYWORDS="~amd64 ~x86"
+IUSE="cm doc examples gev test"
+RESTRICT="!test? ( test )"
+
+BDEPEND="
+       doc? (
+               app-text/doxygen[dot]
+               dev-texlive/texlive-latex
+               dev-texlive/texlive-latexextra
+               dev-texlive/texlive-latexrecommended
+       )
+"
+
+PATCHES=(
+       "${FILESDIR}"/${P}-cmake4.patch
+       "${FILESDIR}"/${P}-cmp0153.patch
+)
+
+src_prepare() {
+       cmake_src_prepare
+
+       sed -i -e '/add_subdirectory(doc)/d' CMakeLists.txt || die
+       # CMake doc building broken
+       # gentoo doc directory
+       #sed -i \
+       #       -e "s:share/HepMC/doc:share/doc/${PF}:" \
+       #       doc/CMakeLists.txt || die
+
+       # gentoo examples directory
+       sed -i \
+               -e "s:share/HepMC:share/doc/${PF}:" \
+               $(find examples -name CMakeLists.txt) || die
+
+       # respect user's flags
+       sed -i \
+               -e "s/-O -ansi -pedantic -Wall//g" \
+               cmake/Modules/HepMCVariables.cmake || die
+
+       # gentoo libdir love
+       sed -i \
+               -e '/DESTINATION/s/lib/lib${LIB_SUFFIX}/g' \
+               {src,fio}/CMakeLists.txt || die
+
+       # remove targets if use flags not set
+       if ! use examples; then
+               sed -i -e '/add_subdirectory(examples)/d' CMakeLists.txt || die
+       fi
+       if ! use test; then
+               sed -i -e '/add_subdirectory(test)/d' CMakeLists.txt || die
+       fi
+
+       # remove static libs
+       sed -i \
+               -e '/(HepMC\(fio\|\)S/d' \
+               -e '/TARGETS/s/HepMC\(fio\|\)S//' \
+               {src,fio}/CMakeLists.txt || die
+}
+
+src_configure() {
+       # error: 'hepevt_' violates the C++ One Definition Rule [-Werror=odr]
+       # Bug 863284
+       filter-lto
+       # use MeV over GeV and mm over cm
+       local mycmakeargs=(
+               -Dlength=$(usex cm CM MM)
+               -Dmomentum=$(usex gev GEV MEV)
+       )
+       cmake_src_configure
+}
+
+src_compile() {
+       cmake_src_compile
+
+       if use doc; then
+               cd doc || die
+               ./buildDoc.sh || die
+               ./buildDoxygen.sh || die
+               HTML_DOCS=( doc/html/. )
+       fi
+}
+
+src_install() {
+       cmake_src_install
+       use doc && dodoc doc/*.pdf
+}

Reply via email to