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 <ast...@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: signature.asc
Description: This is a digitally signed message part.

Reply via email to