diff --git a/app-text/htmltidy/files/htmltidy-5.8.0-cmake4.patch b/app-text/htmltidy/files/htmltidy-5.8.0-cmake4.patch
new file mode 100644
index 0000000000000..f310c370ab697
--- /dev/null
+++ b/app-text/htmltidy/files/htmltidy-5.8.0-cmake4.patch
@@ -0,0 +1,61 @@
+From 237d8b4e96b36d1818f9d9322d25aaa2a58f4dc8 Mon Sep 17 00:00:00 2001
+From: "Douglas R. Reno"
+Date: Wed, 2 Apr 2025 18:58:02 -0500
+Subject: [PATCH] CMakeLists: Adjust for CMake 4.0's removal of deprecated
+ syntax.
+
+CMake 4.0 is more strict than previous versions, and has enforced
+removals of deprecated syntax. Compatibility with versions of CMake
+prior to 3.5 is no longer permitted either, so we'll change it to say
+4.0 to fix that problem. After that, the custom commands for generating
+the manual page need to be adjusted as CMake now needs to know when to
+run commands, so we will generate the manual page after the package is
+built by passing POST_BUILD to the custom commands.
+
+Tested with CMake 4.0 and 3.31.6.
+
+* asturm 2025-04-13: Just raise minimum to 3.10 instead.
+
+---
+ CMakeLists.txt | 6 ++++--
+ 1 file changed, 4 insertions(+), 2 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index a01240e8..20997e7d 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -17,7 +17,7 @@
+ # @date Consult git log.
+ ##############################################################################
+
+-cmake_minimum_required (VERSION 2.8.12)
++cmake_minimum_required (VERSION 3.10)
+
+ set(LIB_NAME tidy)
+ set(LIBTIDY_DESCRIPTION "${LIB_NAME} - HTML syntax checker")
+@@ -528,6 +528,7 @@ if (UNIX AND SUPPORT_CONSOLE_APP)
+
+ # Run the built EXE to generate xml output .
+ add_custom_command(
++ POST_BUILD
+ TARGET man
+ COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${LIB_NAME} -xml-help > ${TIDYHELP}
+ COMMENT "Generate ${TIDYHELP}"
+@@ -536,6 +537,7 @@ if (UNIX AND SUPPORT_CONSOLE_APP)
+
+ # Run the built EXE to generate more xml output.
+ add_custom_command(
++ POST_BUILD
+ TARGET man
+ COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${LIB_NAME} -xml-config > ${TIDYCONFIG}
+ COMMENT "Generate ${TIDYCONFIG}"
+@@ -544,8 +546,8 @@ if (UNIX AND SUPPORT_CONSOLE_APP)
+
+ # Run xsltproc to generate the install files.
+ add_custom_command(
++ POST_BUILD
+ TARGET man
+- DEPENDS ${TIDYHELP}
+ COMMAND xsltproc ARGS ${TIDY1XSL} ${TIDYHELP} > ${CMAKE_CURRENT_BINARY_DIR}/${TIDY_MANFILE}
+ COMMENT "Generate ${TIDY_MANFILE}"
+ VERBATIM
diff --git a/app-text/htmltidy/htmltidy-5.8.0-r2.ebuild b/app-text/htmltidy/htmltidy-5.8.0-r2.ebuild
index c15e89d06162f..8c83d902aee10 100644
--- a/app-text/htmltidy/htmltidy-5.8.0-r2.ebuild
+++ b/app-text/htmltidy/htmltidy-5.8.0-r2.ebuild
@@ -1,19 +1,19 @@
-# Copyright 1999-2024 Gentoo Authors
+# Copyright 1999-2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
-EAPI=7
+EAPI=8
USE_RUBY="ruby26 ruby27 ruby30 ruby31 ruby32"
RUBY_OPTIONAL="yes"
-inherit cmake ruby-ng
-
MY_PN="tidy-html5"
MY_P="${MY_PN}-${PV}"
+inherit cmake ruby-ng
DESCRIPTION="Tidy the layout and correct errors in HTML and XML documents"
HOMEPAGE="https://www.html-tidy.org/"
SRC_URI="https://github.com/htacg/${MY_PN}/archive/refs/tags/${PV}.tar.gz -> ${P}.tar.gz"
+S="${WORKDIR}"/${MY_P}
LICENSE="BSD"
SLOT="0/58" # subslot is SOVERSION
@@ -23,14 +23,13 @@ IUSE="deprecated test"
RESTRICT="!test? ( test )"
ruby_add_bdepend "test? ( dev-ruby/thor dev-ruby/tty-editor )"
-PATCHES=(
- "${FILESDIR}"/${PN}-5.8.0-no_static_lib.patch
- "${FILESDIR}"/${PN}-5.8.0-ol_type.patch
-)
-
DOCS=( README.md README/CHANGELOG.md )
-S="${WORKDIR}"/${MY_P}
+PATCHES=(
+ "${FILESDIR}"/${P}-no_static_lib.patch
+ "${FILESDIR}"/${P}-ol_type.patch
+ "${FILESDIR}"/${P}-cmake4.patch # bug 951860
+)
pkg_setup() {
use test && ruby-ng_pkg_setup
@@ -64,7 +63,7 @@ src_configure() {
src_test() {
cd regression_testing || die
- rm -f Gemfile.lock
+ rm -f Gemfile.lock || die
${RUBY} ./test.rb test -t "${BUILD_DIR}/tidy" || die "Test execution failed"
}