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

    From Andreas Sturmlechner@21:1/5 to All on Sat May 17 22:04:16 2025
    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;