• Re: [gentoo-dev] [PATCH v2 1/3] cmake.eclass: Add recursive CMakeLists.

    From =?UTF-8?Q?Micha=C5=82_G=C3=B3rny?=@21:1/5 to Andreas Sturmlechner on Mon May 19 21:00:01 2025
    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 <[email protected]>
    ---
    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


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

    iQFGBAABCgAwFiEEx2qEUJQJjSjMiybFY5ra4jKeJA4FAmgrfcUSHG1nb3JueUBn ZW50b28ub3JnAAoJEGOa2uIyniQODa4H+wQUhCviLnHWtYbQKCYOEVIiV2B3YmwU U+QyKewRVnS05cJnv/GdRcCWtB2v1eUk2xBpiRggWUx4OSIjG/O+bGiewgFC2b8D zqlR8rzbaVRRByRWf714ZAqNENW+tKOyeGBDijktHkU0U0WidgemgHFnuYxP4HO9 wvCb3XmVZdoddL+fEy+Xka4x065cNMCK/gc/LiEvGHQx0WkT6ddvXHrHSMoegizt O10G/wqYi33AGgTq8GsRc5aQS93Vy45KOxz1LqppioHDuBtIlMVLzuvhFzN0A2fD bEzMAqTjpYc3JfuQmHCl9IAdDRfGN/7viSjt4/mRswoD6m8VXAw7QVU=
    =o/Va
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Andreas Sturmlechner@21:1/5 to All on Mon May 19 20:58:36 2025
    Copy: [email protected] (=?UTF-8?B?TWljaGHFgiBHw7Nybnk=?=)

    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
    -----BEGIN PGP SIGNATURE-----

    iQITBAABCgB9FiEEmaksxp6GvcraXyZQrlkbvHPk3V4FAmgrf1xfFIAAAAAALgAo aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDk5 QTkyQ0M2OUU4NkJEQ0FEQTVGMjY1MEFFNTkxQkJDNzNFNERENUUACgkQrlkbvHPk 3V4RVwwAmKAfvjkgikY5kEEiuTegDeb2vafCxh1pEkl7lFwlAMFYNuXaP+Rwm2Oa bi0TNIFkwyjimj3N/czJqOy9QTvpuTi1pkGlhbB8wu4mhxM+GCZt34MbcLVJgt57 w64ACmCX4lgQUeOjuE3GagBomp/5KlbOsRYzYlKTF7udK6CSni0LV+/dvXJJAT09 nORCLi0zJ4CxqxdzsOrgsxRRtaPVsW6xpl0SxkNWWLR6l8+7CS5fWJO94/wReuIM ANSt+eHztidxuw7VN7CkukDSLwvNhcwsc2C9M30JVQC9Xubqum4UtOiJDaq5KA4i EYXy1onAGLXCfqZV3Xl2ADHekImRf/j+GnHwgYa6wqBZ3nFVGOZVPCMn7bT5zkld cQB8dabrILbH2S0ttmAlk0cNbR1FifBneQ3RK1yyiiJUaNe21BGShC5qB+4w273h PtJQn0LzRvN7t/U+muTdxW/OPNV7M5VoYBhs0QZSijtJYRAqoGhITGM/Mml8PPmf
    7oXm2IbV
    =rct7
    -----END PGP SIGNATURE-----

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