• Re: [gentoo-dev] [PATCH] cmake.eclass: Add recursive CMakeLists.txt uns

    From Ionen Wolkens@21:1/5 to Ionen Wolkens on Sat May 17 23:10:01 2025
    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

    -----BEGIN PGP SIGNATURE-----

    iQEzBAABCAAdFiEEx3SLh1HBoPy/yLVYskQGsLCsQzQFAmgo+a0ACgkQskQGsLCs QzRn+wgAy9QspZgkHbR+/96ZBUz5xCkHBQl1lgPE0aCwYQCDDSy1LKAY7PiCWE79 SG3ewSBPhutqj3sbRWJDJAk2l8T5oTDDwzVVMiNztwJ4y6gG8H5n7RQykJu79Cda cwD4RJn7qSsVoYJ5zsbo/PaZgBZtb5b/ozTb5buh5M730KpeZHgu6Ywa4ZV/+v+c Oh3bGmwfVBLUD5HpCIcL2qpZj3IEGwQkDheySxxWZqgEfhOUe0ICeGvRdot5iwHD ncT1UXaF+L99cURBYOqmXgGIV39FLC9Eeqm9+UiuiZpGrV2QTpw114SqPFIWsaAe 5eHjya6KHGyDCYrpcd6pIBpwg70qiA==
    =WwCZ
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ionen Wolkens@21:1/5 to Andreas Sturmlechner on Sat May 17 22:50:01 2025
    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

    -----BEGIN PGP SIGNATURE-----

    iQEzBAABCAAdFiEEx3SLh1HBoPy/yLVYskQGsLCsQzQFAmgo9LYACgkQskQGsLCs QzQbCQgAwpUPGztnE8cA4Hf0ONu4ROeXXOPDWluvDOteCw2CIsGFPEfaBmMOokFQ U5Z00vkpU+Fp62vhWOplp8yBEe2FZsv5/UmYht7VL4bdH959jtp4t2jrSNLUslfm DKO9BboZIqm+GV3S+iFsHUaokiubNx+a81G46KN8MGZLr3XXy4S09YFiHJxCj0jz iXRnTaWC6ilG2AxnDZ86+sdKEjFbLkOA+J+S5RpL83atQxJMLW8EUhzG9Si1/JcR gTdQYvT8nl87iTuvg0xsMV0C2rULikjDKWaHi5TAindKgfFDbI4jkD7JDz0nLMVZ WUoOF1X7V4I8LE5zNNjT7C/A2OOnMA==
    =ns18
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Andreas Sturmlechner@21:1/5 to All on Sat May 17 23:30:34 2025
    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
    -----BEGIN PGP SIGNATURE-----

    iQITBAABCgB9FiEEmaksxp6GvcraXyZQrlkbvHPk3V4FAmgo//pfFIAAAAAALgAo aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDk5 QTkyQ0M2OUU4NkJEQ0FEQTVGMjY1MEFFNTkxQkJDNzNFNERENUUACgkQrlkbvHPk 3V6wqAwAkiTmywRCVEwBFB8t738uQtzYh5Qf6hFY6hQOxv6dVC6X+2L8h0h2wEsu 0jv2Iek/UgL1mMqGz28JDnMvTILr55TziYBcpmppqRRcm/dmDh4UCs1mo52yDkUW NNxB3oYZY7uf6BeyCQ2xaS2QHL7ciiIJmogvY29rn0Ps0eMRc0vIHLWl1MmvQTKK sUfjN9U1UdmpWvuuhINrQQzSAfNcfb1/vCyf7R4uDUwDeEKrESZ8eK+jSmQQkwla UbSXcDp/ol/w/JTPAAGPa+BzorpjMCcRdGDXTbvVCgh4fHui/P5P0knPUQaGXGtQ zGuN2VVDJ3xouaJdgyouvK5wHLYjCZWYx5MRVp3h5+Rw2cyHCnCp45TuERFgzqj9 JgNlo7+tYDby6A48dGG2q+KyEDXscCNrW2RiRnTUfoNoPuD/g+JXhPOwZDMX5oUx e3vfNO1I00wdVKypNHULACATBsVMzmlPm7MN3tH4FpS5KtApI7TrtyYKjEMVoJ6N
    +h3hrO1e
    =itH/
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Eli Schwartz@21:1/5 to Ionen Wolkens on Sun May 18 04:50:01 2025
    This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --------------j0HDOuZBCM4IzTcsg1qiI5gT
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: quoted-printable

    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

    --------------j0HDOuZBCM4IzTcsg1qiI5gT--

    -----BEGIN PGP SIGNATURE-----

    wnsEABYIACMWIQTnFNnmK0TPZHnXm3qEp9ErcA0vVwUCaClJJQUDAAAAAAAKCRCEp9ErcA0vV7Fx AQDCuQfOErkr+4CpQedhglDVrrMaoEY1BgUh22ItGI3gUgD/fzHQ5i3KzZmTR+xBxaJbXJHqSv5Q bj4siENIq565mg4=
    =+w3/
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)