* [gentoo-dev] [PATCH] cmake.eclass: Add recursive CMakeLists.txt unsupported version detection @ 2025-05-17 20:04 Andreas Sturmlechner 2025-05-17 20:42 ` Ionen Wolkens ` (2 more replies) 0 siblings, 3 replies; 13+ messages in thread From: Andreas Sturmlechner @ 2025-05-17 20:04 UTC (permalink / raw To: gentoo-dev, kde, base-system [-- Attachment #1: Type: text/plain, Size: 2571 bytes --] 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 \ + 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 [-- Attachment #2: This is a digitally signed message part. --] [-- Type: application/pgp-signature, Size: 789 bytes --] ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [gentoo-dev] [PATCH] cmake.eclass: Add recursive CMakeLists.txt unsupported version detection 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 2025-05-17 21:03 ` Ionen Wolkens 2025-05-18 2:42 ` Eli Schwartz 2025-05-19 18:44 ` [gentoo-dev] [PATCH v2 1/3] " Andreas Sturmlechner 2025-06-02 20:44 ` [gentoo-dev] [PATCH v3 " Andreas Sturmlechner 2 siblings, 2 replies; 13+ messages in thread From: Ionen Wolkens @ 2025-05-17 20:42 UTC (permalink / raw To: gentoo-dev; +Cc: kde, base-system [-- 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 --] ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [gentoo-dev] [PATCH] cmake.eclass: Add recursive CMakeLists.txt unsupported version detection 2025-05-17 20:42 ` Ionen Wolkens @ 2025-05-17 21:03 ` Ionen Wolkens 2025-05-17 21:30 ` Andreas Sturmlechner 2025-05-18 2:42 ` Eli Schwartz 1 sibling, 1 reply; 13+ messages in thread From: Ionen Wolkens @ 2025-05-17 21:03 UTC (permalink / raw To: gentoo-dev, kde, base-system [-- Attachment #1: Type: text/plain, Size: 3924 bytes --] On Sat, May 17, 2025 at 04:42:30PM -0400, Ionen Wolkens wrote: > 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 ]] Missing quotes on "$x" for spaces too. Haven't looked at that closely code-wise though, it'd be nicer to avoid doing grep twice. > > + 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 -- ionen [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 488 bytes --] ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [gentoo-dev] [PATCH] cmake.eclass: Add recursive CMakeLists.txt unsupported version detection 2025-05-17 21:03 ` Ionen Wolkens @ 2025-05-17 21:30 ` Andreas Sturmlechner 0 siblings, 0 replies; 13+ messages in thread From: Andreas Sturmlechner @ 2025-05-17 21:30 UTC (permalink / raw To: gentoo-dev, kde, base-system [-- Attachment #1: Type: text/plain, Size: 1019 bytes --] On Samstag, 17. Mai 2025 22:42:30 Mitteleuropäische Sommerzeit Ionen Wolkens wrote: > 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. On Samstag, 17. Mai 2025 23:03:42 Mitteleuropäische Sommerzeit Ionen Wolkens wrote: > Haven't looked at that closely code-wise though, it'd be nicer to > avoid doing grep twice. Could address both points by limiting the crawling to maxdepth 1 or 2 and always do the regex, without pre-filtering through a first grep, and probably catch most of the brokenness. However, that would have already failed media-libs/opencv-4.10 which in its most extreme case had too low a minimum version even 6 subdirs deep... otoh I already know of at least digikam also causing false warnings in its subdirs - but then these are only one or two upstream build system changes away from becoming errors. Regards [-- Attachment #2: This is a digitally signed message part. --] [-- Type: application/pgp-signature, Size: 789 bytes --] ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [gentoo-dev] [PATCH] cmake.eclass: Add recursive CMakeLists.txt unsupported version detection 2025-05-17 20:42 ` Ionen Wolkens 2025-05-17 21:03 ` Ionen Wolkens @ 2025-05-18 2:42 ` Eli Schwartz 1 sibling, 0 replies; 13+ messages in thread From: Eli Schwartz @ 2025-05-18 2:42 UTC (permalink / raw To: gentoo-dev [-- Attachment #1.1: Type: text/plain, Size: 2281 bytes --] On 5/17/25 4:42 PM, Ionen Wolkens wrote: > 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. It has come up in other contexts as well, that eqawarns should probably (and unfortunately all too often do not) come with a variable that ebuilds can set to disable false positives, e.g. QA_CONFIG_IMPL_DECL_SKIP So let us say QA_CMAKE_COMPAT_SKIP=( 'path/to/unused subdir/' ) -- Eli Schwartz [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 236 bytes --] ^ permalink raw reply [flat|nested] 13+ messages in thread
* [gentoo-dev] [PATCH v2 1/3] cmake.eclass: Add recursive CMakeLists.txt unsupported version detection 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 @ 2025-05-19 18:44 ` 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 ` (2 more replies) 2025-06-02 20:44 ` [gentoo-dev] [PATCH v3 " Andreas Sturmlechner 2 siblings, 3 replies; 13+ messages in thread From: Andreas Sturmlechner @ 2025-05-19 18:44 UTC (permalink / raw To: gentoo-dev, kde, base-system [-- Attachment #1: Type: text/plain, Size: 2085 bytes --] 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 | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/eclass/cmake.eclass b/eclass/cmake.eclass index 083b566d26..ca6c03f335 100644 --- a/eclass/cmake.eclass +++ b/eclass/cmake.eclass @@ -362,6 +362,18 @@ cmake_src_configure() { # Fix xdg collision with sandbox xdg_environment_reset + local file re="cmake_minimum_required *\( *VERSION( .*\.\.\.| )(([[:digit:]]+)\.([[:digit:]]+))" + local ver cmreq_isold + while read -d '' -r file ; do + [[ $(grep -hi "cmake_minimum_required" "$file") =~ $re ]] + ver="${BASH_REMATCH[2]}" + echo $file $ver + + if [[ -n $ver ]] && ver_test $ver -lt "3.5"; then + cmreq_isold=true + fi + done < <(find "${CMAKE_USE_DIR}" -type f -iname "CMakeLists.txt" -print0) + # Prepare Gentoo override rules (set valid compiler, append CPPFLAGS etc.) local build_rules=${BUILD_DIR}/gentoo_rules.cmake @@ -543,6 +555,13 @@ cmake_src_configure() { cmakeargs+=( -C "${CMAKE_EXTRA_CACHE_FILE}" ) fi + if [[ ${cmreq_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 + pushd "${BUILD_DIR}" > /dev/null || die debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: mycmakeargs is ${mycmakeargs_local[*]}" echo "${CMAKE_BINARY}" "${cmakeargs[@]}" "${CMAKE_USE_DIR}" -- 2.49.0 [-- Attachment #2: This is a digitally signed message part. --] [-- Type: application/pgp-signature, Size: 789 bytes --] ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [gentoo-dev] [PATCH v2 2/3] cmake.eclass: If CMake 4 is detected, build w/ compat cmake arg 2025-05-19 18:44 ` [gentoo-dev] [PATCH v2 1/3] " Andreas Sturmlechner @ 2025-05-19 18:46 ` 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 2 siblings, 0 replies; 13+ messages in thread From: Andreas Sturmlechner @ 2025-05-19 18:46 UTC (permalink / raw To: gentoo-dev, kde, base-system [-- Attachment #1: Type: text/plain, Size: 782 bytes --] -DCMAKE_POLICY_VERSION_MINIMUM=3.5 Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org> --- eclass/cmake.eclass | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/eclass/cmake.eclass b/eclass/cmake.eclass index ca6c03f335..8e3454fca5 100644 --- a/eclass/cmake.eclass +++ b/eclass/cmake.eclass @@ -560,6 +560,10 @@ cmake_src_configure() { 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." + if has_version -b ">=dev-build/cmake-4"; then + eqawarn "QA Notice: CMake 4 detected; building with -DCMAKE_POLICY_VERSION_MINIMUM=3.5" + cmakeargs+=( -DCMAKE_POLICY_VERSION_MINIMUM=3.5 ) + fi fi pushd "${BUILD_DIR}" > /dev/null || die -- 2.49.0 [-- Attachment #2: This is a digitally signed message part. --] [-- Type: application/pgp-signature, Size: 789 bytes --] ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [gentoo-dev] [PATCH v2 3/3] cmake.eclass: Add CMAKE_QA_COMPAT_SKIP flag to skip compat checks 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 ` 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 2 siblings, 0 replies; 13+ messages in thread From: Andreas Sturmlechner @ 2025-05-19 18:47 UTC (permalink / raw To: gentoo-dev, kde, base-system [-- Attachment #1: Type: text/plain, Size: 1667 bytes --] --- eclass/cmake.eclass | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/eclass/cmake.eclass b/eclass/cmake.eclass index 8e3454fca5..d9013fbc01 100644 --- a/eclass/cmake.eclass +++ b/eclass/cmake.eclass @@ -117,6 +117,12 @@ fi # for econf and is needed to pass TRY_RUN results when cross-compiling. # Should be set by user in a per-package basis in /etc/portage/package.env. +# @ECLASS_VARIABLE: CMAKE_QA_COMPAT_SKIP +# @DEFAULT_UNSET +# @DESCRIPTION: +# If set, skip detection of CMakeLists.txt unsupported in CMake 4 in case of +# false positives (e.g. unused outdated bundled libs). + # @ECLASS_VARIABLE: CMAKE_QA_SRC_DIR_READONLY # @USER_VARIABLE # @DEFAULT_UNSET @@ -364,15 +370,16 @@ cmake_src_configure() { local file re="cmake_minimum_required *\( *VERSION( .*\.\.\.| )(([[:digit:]]+)\.([[:digit:]]+))" local ver cmreq_isold - while read -d '' -r file ; do - [[ $(grep -hi "cmake_minimum_required" "$file") =~ $re ]] - ver="${BASH_REMATCH[2]}" - echo $file $ver - - if [[ -n $ver ]] && ver_test $ver -lt "3.5"; then - cmreq_isold=true - fi - done < <(find "${CMAKE_USE_DIR}" -type f -iname "CMakeLists.txt" -print0) + if ! [[ ${CMAKE_QA_COMPAT_SKIP} ]]; then + while read -d '' -r file ; do + [[ $(grep -hi "cmake_minimum_required" "$file") =~ $re ]] + ver="${BASH_REMATCH[2]}" + + if [[ -n $ver ]] && ver_test $ver -lt "3.5"; then + cmreq_isold=true + fi + done < <(find "${CMAKE_USE_DIR}" -type f -iname "CMakeLists.txt" -print0) + fi # Prepare Gentoo override rules (set valid compiler, append CPPFLAGS etc.) local build_rules=${BUILD_DIR}/gentoo_rules.cmake -- 2.49.0 [-- Attachment #2: This is a digitally signed message part. --] [-- Type: application/pgp-signature, Size: 789 bytes --] ^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [gentoo-dev] [PATCH v2 1/3] cmake.eclass: Add recursive CMakeLists.txt unsupported version detection 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 ` Michał Górny 2025-05-19 18:58 ` Andreas Sturmlechner 2 siblings, 1 reply; 13+ messages in thread From: Michał Górny @ 2025-05-19 18:51 UTC (permalink / raw To: gentoo-dev, kde, base-system [-- Attachment #1: Type: text/plain, Size: 2557 bytes --] On Mon, 2025-05-19 at 20:44 +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 | 19 +++++++++++++++++++ > 1 file changed, 19 insertions(+) > > diff --git a/eclass/cmake.eclass b/eclass/cmake.eclass > index 083b566d26..ca6c03f335 100644 > --- a/eclass/cmake.eclass > +++ b/eclass/cmake.eclass > @@ -362,6 +362,18 @@ cmake_src_configure() { > # Fix xdg collision with sandbox > xdg_environment_reset > > + local file re="cmake_minimum_required *\( *VERSION( .*\.\.\.| )(([[:digit:]]+)\.([[:digit:]]+))" > + local ver cmreq_isold > + while read -d '' -r file ; do > + [[ $(grep -hi "cmake_minimum_required" "$file") =~ $re ]] > + ver="${BASH_REMATCH[2]}" So... you're using grep to find a line containing "cmake_minimum_required", then applying another regexp to that line? This really looks like a case for a single sed call. > + echo $file $ver Is this leftover debug? > + > + if [[ -n $ver ]] && ver_test $ver -lt "3.5"; then > + cmreq_isold=true > + fi > + done < <(find "${CMAKE_USE_DIR}" -type f -iname "CMakeLists.txt" -print0) || die > + > # Prepare Gentoo override rules (set valid compiler, append CPPFLAGS etc.) > local build_rules=${BUILD_DIR}/gentoo_rules.cmake > > @@ -543,6 +555,13 @@ cmake_src_configure() { > cmakeargs+=( -C "${CMAKE_EXTRA_CACHE_FILE}" ) > fi > > + if [[ ${cmreq_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 > + > pushd "${BUILD_DIR}" > /dev/null || die > debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: mycmakeargs is ${mycmakeargs_local[*]}" > echo "${CMAKE_BINARY}" "${cmakeargs[@]}" "${CMAKE_USE_DIR}" -- Best regards, Michał Górny [-- Attachment #2: This is a digitally signed message part --] [-- Type: application/pgp-signature, Size: 512 bytes --] ^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [gentoo-dev] [PATCH v2 1/3] cmake.eclass: Add recursive CMakeLists.txt unsupported version detection 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 0 siblings, 0 replies; 13+ messages in thread From: Andreas Sturmlechner @ 2025-05-19 18:58 UTC (permalink / raw To: gentoo-dev, kde, base-system; +Cc: Michał Górny [-- Attachment #1: Type: text/plain, Size: 923 bytes --] On Montag, 19. Mai 2025 20:51:49 Mitteleuropäische Sommerzeit Michał Górny wrote: > > --- a/eclass/cmake.eclass > > +++ b/eclass/cmake.eclass > > @@ -362,6 +362,18 @@ cmake_src_configure() { > > > > # Fix xdg collision with sandbox > > xdg_environment_reset > > > > + local file re="cmake_minimum_required *\( *VERSION( .*\.\.\.| > > )(([[:digit:]]+)\.([[:digit:]]+))" + local ver cmreq_isold > > + while read -d '' -r file ; do > > + [[ $(grep -hi "cmake_minimum_required" "$file") =~ $re ]] > > + ver="${BASH_REMATCH[2]}" > > So... you're using grep to find a line containing > "cmake_minimum_required", then applying another regexp to that line? > This really looks like a case for a single sed call. I'm glad for any suggestions there. > > > + echo $file $ver > > Is this leftover debug? Indeed, thanks. PR is here: https://github.com/gentoo/kde/pull/1043 Regards [-- Attachment #2: This is a digitally signed message part. --] [-- Type: application/pgp-signature, Size: 789 bytes --] ^ permalink raw reply [flat|nested] 13+ messages in thread
* [gentoo-dev] [PATCH v3 1/3] cmake.eclass: Add recursive CMakeLists.txt unsupported version detection 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 2025-05-19 18:44 ` [gentoo-dev] [PATCH v2 1/3] " Andreas Sturmlechner @ 2025-06-02 20:44 ` 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 2 siblings, 2 replies; 13+ messages in thread From: Andreas Sturmlechner @ 2025-06-02 20:44 UTC (permalink / raw To: gentoo-dev, kde, base-system [-- Attachment #1: Type: text/plain, Size: 2686 bytes --] 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. Problems fixed along the way: - Make sed case-insensitive - CMake version range may have double- or triple-dots - Exit after first match We don't want more than one version for the subsequent ver_test. Besides, any follow-up cmake_minimum_required call will most likely be conditional for some type of workarounds. Thanks-to: Sam James <sam@gentoo.org> Thanks-to: Ionen Wolkens <ionen@gentoo.org> Thanks-to: Michał Górny <mgorny@gentoo.org> Bug: https://bugs.gentoo.org/951350 Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org> --- eclass/cmake.eclass | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/eclass/cmake.eclass b/eclass/cmake.eclass index c97f74e8a2ed..4c91afa160d9 100644 --- a/eclass/cmake.eclass +++ b/eclass/cmake.eclass @@ -445,6 +445,17 @@ cmake_src_configure() { # Fix xdg collision with sandbox xdg_environment_reset + local file ver cmreq_isold + while read -d '' -r file ; do + ver=$(sed -ne "/cmake_minimum_required/I{s/.*\(\.\.\.*\|\s\)\([0-9.]*\)\([)]\|\s\).*$/\2/p;q}" \ + "${file}" 2>/dev/null \ + ) + + if [[ -n $ver ]] && ver_test $ver -lt "3.5"; then + cmreq_isold=true + fi + done < <(find "${CMAKE_USE_DIR}" -type f -iname "CMakeLists.txt" -print0) + # Prepare Gentoo override rules (set valid compiler, append CPPFLAGS etc.) local build_rules=${BUILD_DIR}/gentoo_rules.cmake @@ -625,6 +636,16 @@ cmake_src_configure() { cmakeargs+=( -C "${CMAKE_EXTRA_CACHE_FILE}" ) fi + if [[ ${cmreq_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, and take it upstream." + if [[ ${EAPI} == 7 ]]; then + eqawarn "QA Notice: EAPI=7 detected; this package is now a prime last-rites target." + fi + fi + pushd "${BUILD_DIR}" > /dev/null || die debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: mycmakeargs is ${mycmakeargs_local[*]}" echo "${CMAKE_BINARY}" "${cmakeargs[@]}" "${CMAKE_USE_DIR}" -- 2.49.0 [-- Attachment #2: This is a digitally signed message part. --] [-- Type: application/pgp-signature, Size: 789 bytes --] ^ permalink raw reply related [flat|nested] 13+ messages in thread
* [gentoo-dev] [PATCH v3 2/3] cmake.eclass: If CMake 4 is detected, build w/ compat cmake arg 2025-06-02 20:44 ` [gentoo-dev] [PATCH v3 " Andreas Sturmlechner @ 2025-06-02 20:46 ` 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 1 sibling, 0 replies; 13+ messages in thread From: Andreas Sturmlechner @ 2025-06-02 20:46 UTC (permalink / raw To: gentoo-dev, kde, base-system [-- Attachment #1: Type: text/plain, Size: 809 bytes --] -DCMAKE_POLICY_VERSION_MINIMUM=3.5 Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org> --- eclass/cmake.eclass | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/eclass/cmake.eclass b/eclass/cmake.eclass index 4c91afa160d9..b538af80a4b1 100644 --- a/eclass/cmake.eclass +++ b/eclass/cmake.eclass @@ -644,6 +644,11 @@ cmake_src_configure() { if [[ ${EAPI} == 7 ]]; then eqawarn "QA Notice: EAPI=7 detected; this package is now a prime last-rites target." fi + if has_version -b ">=dev-build/cmake-4"; then + eqawarn "QA Notice: CMake 4 detected; building with -DCMAKE_POLICY_VERSION_MINIMUM=3.5" + eqawarn "This is merely a workaround and *not* a permanent fix." + cmakeargs+=( -DCMAKE_POLICY_VERSION_MINIMUM=3.5 ) + fi fi pushd "${BUILD_DIR}" > /dev/null || die -- 2.49.0 [-- Attachment #2: This is a digitally signed message part. --] [-- Type: application/pgp-signature, Size: 789 bytes --] ^ permalink raw reply related [flat|nested] 13+ messages in thread
* [gentoo-dev] [PATCH v3 3/3] cmake.eclass: Add CMAKE_QA_COMPAT_SKIP flag to skip compat checks 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 ` Andreas Sturmlechner 1 sibling, 0 replies; 13+ messages in thread From: Andreas Sturmlechner @ 2025-06-02 20:47 UTC (permalink / raw To: gentoo-dev, kde, base-system [-- Attachment #1: Type: text/plain, Size: 1728 bytes --] Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org> --- eclass/cmake.eclass | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/eclass/cmake.eclass b/eclass/cmake.eclass index b538af80a4b1..f327521e9fc1 100644 --- a/eclass/cmake.eclass +++ b/eclass/cmake.eclass @@ -117,6 +117,12 @@ fi # for econf and is needed to pass TRY_RUN results when cross-compiling. # Should be set by user in a per-package basis in /etc/portage/package.env. +# @ECLASS_VARIABLE: CMAKE_QA_COMPAT_SKIP +# @DEFAULT_UNSET +# @DESCRIPTION: +# If set, skip detection of CMakeLists.txt unsupported in CMake 4 in case of +# false positives (e.g. unused outdated bundled libs). + # @ECLASS_VARIABLE: CMAKE_QA_SRC_DIR_READONLY # @USER_VARIABLE # @DEFAULT_UNSET @@ -446,15 +452,17 @@ cmake_src_configure() { xdg_environment_reset local file ver cmreq_isold - while read -d '' -r file ; do - ver=$(sed -ne "/cmake_minimum_required/I{s/.*\(\.\.\.*\|\s\)\([0-9.]*\)\([)]\|\s\).*$/\2/p;q}" \ - "${file}" 2>/dev/null \ - ) - - if [[ -n $ver ]] && ver_test $ver -lt "3.5"; then - cmreq_isold=true - fi - done < <(find "${CMAKE_USE_DIR}" -type f -iname "CMakeLists.txt" -print0) + if ! [[ ${CMAKE_QA_COMPAT_SKIP} ]]; then + while read -d '' -r file ; do + ver=$(sed -ne "/cmake_minimum_required/I{s/.*\(\.\.\.*\|\s\)\([0-9.]*\)\([)]\|\s\).*$/\2/p;q}" \ + "${file}" 2>/dev/null \ + ) + + if [[ -n $ver ]] && ver_test $ver -lt "3.5"; then + cmreq_isold=true + fi + done < <(find "${CMAKE_USE_DIR}" -type f -iname "CMakeLists.txt" -print0) + fi # Prepare Gentoo override rules (set valid compiler, append CPPFLAGS etc.) local build_rules=${BUILD_DIR}/gentoo_rules.cmake -- 2.49.0 [-- Attachment #2: This is a digitally signed message part. --] [-- Type: application/pgp-signature, Size: 789 bytes --] ^ permalink raw reply related [flat|nested] 13+ messages in thread
end of thread, other threads:[~2025-06-02 20:48 UTC | newest] Thread overview: 13+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 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
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox