public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: Ionen Wolkens <ionen@gentoo.org>
To: gentoo-dev@lists.gentoo.org
Cc: kde@gentoo.org, base-system@gentoo.org
Subject: Re: [gentoo-dev] [PATCH] cmake.eclass: Add recursive CMakeLists.txt unsupported version detection
Date: Sat, 17 May 2025 16:42:30 -0400	[thread overview]
Message-ID: <aCj0tmEtkTDR2ikF@eversor> (raw)
In-Reply-To: <12677532.O9o76ZdvQC@tuxbrain.fritz.box>

[-- Attachment #1: Type: text/plain, Size: 3550 bytes --]

On Sat, May 17, 2025 at 10:04:16PM +0200, Andreas Sturmlechner wrote:
> We need to ramp up detection of unsupported CMake build systems with
> CMake 4. This will detect CMakeLists.txt files setting insufficient
> cmake_minimum_required VERSION level even in project subdirectories,
> putting out appropriate eqawarn message about the need to fix ${PN}.
> 
> That makes us not rely on tinderbox runs w/ unmasked cmake-4 slowly
> being able to build everything up to leaf packages, and also helps
> detect insufficient subproject minimums that could otherwise be masked
> by USE flag choice.
> 
> Bug: https://bugs.gentoo.org/951350
> Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
> ---
>  eclass/cmake.eclass | 20 +++++++++++++++++++-
>  1 file changed, 19 insertions(+), 1 deletion(-)
> 
> diff --git a/eclass/cmake.eclass b/eclass/cmake.eclass
> index 083b566d26..8a3f2db7c4 100644
> --- a/eclass/cmake.eclass
> +++ b/eclass/cmake.eclass
> @@ -243,6 +243,25 @@ _cmake_modify-cmakelists() {
>  	# Only edit the files once
>  	grep -qs "<<< Gentoo configuration >>>" "${CMAKE_USE_DIR}"/CMakeLists.txt && return 0
>  
> +	local x re="VERSION( .*\.\.\.| )(([[:digit:]]+)\.([[:digit:]]+))"
> +	local ver isold
> +	for x in $(find "${CMAKE_USE_DIR}" -type f -iname "CMakeLists.txt" -exec \

Just to note, may be rare so guess not a big deal but, while crawling
all sub-directories, it could pickup some extra CMakeLists.txt that are
entirely unused (by us) and don't need attention downstream. Some
packages keep a lot of weird unused stuff, or bits that we disable or
unbundle, e.g. qtwebengine adds BUILD.gn files for 3rdparty stuff but
the (unused) upstream CMakeLists.txt are often left there and I wouldn't
want a QA bug filed over that if any were bad.

May be hard to get the real picture without just testing with cmake-4.

That aside, there "could" be spaces in all the subdirs, I'd suggest
a `while IFS= read -r -d '' x; do [...] done < <(find [...] -print0)
loop instead, or mapfile.

> +		grep -li "cmake_minimum_required\s*(.*)" {} \;); do
> +
> +		[[ $(grep -hi "cmake_minimum_required" $x) =~ $re ]]
> +		ver="${BASH_REMATCH[2]}"
> +
> +		if ver_test $ver -lt "3.5"; then
> +			isold=true
> +		fi
> +	done
> +	if [[ ${isold} ]]; then
> +		eqawarn "QA Notice: Compatibility with CMake < 3.5 has been removed from CMake 4,"
> +		eqawarn "${CATEGORY}/${PN} will fail to build w/o a fix."
> +		eqawarn "See also tracker bug #951350; check existing bug or file a new one for"
> +		eqawarn "this package."
> +	fi
> +
>  	# Comment out all set (<some_should_be_user_defined_variable> value)
>  	find "${CMAKE_USE_DIR}" -name CMakeLists.txt -exec sed \
>  		-e '/^[[:space:]]*set[[:space:]]*([[:space:]]*CMAKE_BUILD_TYPE\([[:space:]].*)\|)\)/I{s/^/#_cmake_modify_IGNORE /g}' \
> @@ -250,7 +269,6 @@ _cmake_modify-cmakelists() {
>  		-e '/^[[:space:]]*set[[:space:]]*([[:space:]]*CMAKE_INSTALL_PREFIX[[:space:]].*)/I{s/^/#_cmake_modify_IGNORE /g}' \
>  		-e '/^[[:space:]]*set[[:space:]]*([[:space:]]*CMAKE_VERBOSE_MAKEFILE[[:space:]].*)/I{s/^/#_cmake_modify_IGNORE /g}' \
>  		-i {} + || die "${LINENO}: failed to disable hardcoded settings"
> -	local x
>  	for x in $(find "${CMAKE_USE_DIR}" -name CMakeLists.txt -exec grep -l "^#_cmake_modify_IGNORE" {} +;); do
>  		einfo "Hardcoded definition(s) removed in $(echo "${x}" | cut -c $((${#CMAKE_USE_DIR}+2))-):"
>  		einfo "$(grep -se '^#_cmake_modify_IGNORE' ${x} | cut -c 22-99)"
> -- 
> 2.49.0



-- 
ionen

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2025-05-17 20:43 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-17 20:04 [gentoo-dev] [PATCH] cmake.eclass: Add recursive CMakeLists.txt unsupported version detection Andreas Sturmlechner
2025-05-17 20:42 ` Ionen Wolkens [this message]
2025-05-17 21:03   ` Ionen Wolkens
2025-05-17 21:30     ` Andreas Sturmlechner
2025-05-18  2:42   ` Eli Schwartz
2025-05-19 18:44 ` [gentoo-dev] [PATCH v2 1/3] " Andreas Sturmlechner
2025-05-19 18:46   ` [gentoo-dev] [PATCH v2 2/3] cmake.eclass: If CMake 4 is detected, build w/ compat cmake arg Andreas Sturmlechner
2025-05-19 18:47   ` [gentoo-dev] [PATCH v2 3/3] cmake.eclass: Add CMAKE_QA_COMPAT_SKIP flag to skip compat checks Andreas Sturmlechner
2025-05-19 18:51   ` [gentoo-dev] [PATCH v2 1/3] cmake.eclass: Add recursive CMakeLists.txt unsupported version detection Michał Górny
2025-05-19 18:58     ` Andreas Sturmlechner
2025-06-02 20:44 ` [gentoo-dev] [PATCH v3 " Andreas Sturmlechner
2025-06-02 20:46   ` [gentoo-dev] [PATCH v3 2/3] cmake.eclass: If CMake 4 is detected, build w/ compat cmake arg Andreas Sturmlechner
2025-06-02 20:47   ` [gentoo-dev] [PATCH v3 3/3] cmake.eclass: Add CMAKE_QA_COMPAT_SKIP flag to skip compat checks Andreas Sturmlechner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aCj0tmEtkTDR2ikF@eversor \
    --to=ionen@gentoo.org \
    --cc=base-system@gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    --cc=kde@gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox