• [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;
  • From Andreas Sturmlechner@21:1/5 to All on Mon May 19 20:44:29 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 | 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 [[
  • From Andreas Sturmlechner@21:1/5 to All on Mon May 19 20:46:15 2025
    -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


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

    iQITBAABCgB9FiEEmaksxp6GvcraXyZQrlkbvHPk3V4FAmgrfHdfFIAAAAAALgAo aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDk5 QTkyQ0M2OUU4NkJEQ0FEQTVGMjY1MEFFNTkxQkJDNzNFNERENUUACgkQrlkbvHPk 3V7Qhgv9GbGnQZ40j1m4SIJOuDl+zJTqqwmn9bZeE1GiUFR6QjK7Ay9aviUzKcnP OPVV1wZkOWDbsFv
  • From Andreas Sturmlechner@21:1/5 to All on Mon May 19 20:47:05 2025
    ---
    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="${BAS
  • From Andreas Sturmlechner@21:1/5 to All on Mon Jun 2 22:44:34 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.

    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: Compatibilit