From 36eee9f1329af293a276cba164e0f6256af2d1d5 Mon Sep 17 00:00:00 2001 From: Andreas Sturmlechner Date: Sat, 17 May 2025 19:09:31 +0200 Subject: [PATCH 1/4] cmake.eclass: Add recursive CMakeLists.txt unsupported version detection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Thanks-to: Ionen Wolkens Thanks-to: Michał Górny Bug: https://bugs.gentoo.org/951350 Signed-off-by: Andreas Sturmlechner --- eclass/cmake.eclass | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/eclass/cmake.eclass b/eclass/cmake.eclass index c97f74e8a2eda..4c91afa160d9a 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: 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, and take it upstream." + if [[ ${EAPI} == 7 ]]; then + eqawarn "QA Notice: EAPI=7 detected; this package is now a prime last-rites target." + fi + fi + pushd "${BUILD_DIR}" > /dev/null || die debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: mycmakeargs is ${mycmakeargs_local[*]}" echo "${CMAKE_BINARY}" "${cmakeargs[@]}" "${CMAKE_USE_DIR}" From 4f0e629df3f6e44565becf3dc238d6d65ae9c102 Mon Sep 17 00:00:00 2001 From: Andreas Sturmlechner Date: Mon, 19 May 2025 18:36:57 +0200 Subject: [PATCH 2/4] cmake.eclass: If CMake 4 is detected, build w/ compat cmake arg -DCMAKE_POLICY_VERSION_MINIMUM=3.5 Signed-off-by: Andreas Sturmlechner --- eclass/cmake.eclass | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/eclass/cmake.eclass b/eclass/cmake.eclass index 4c91afa160d9a..b538af80a4b10 100644 --- a/eclass/cmake.eclass +++ b/eclass/cmake.eclass @@ -644,6 +644,11 @@ cmake_src_configure() { if [[ ${EAPI} == 7 ]]; then eqawarn "QA Notice: EAPI=7 detected; this package is now a prime last-rites target." fi + if has_version -b ">=dev-build/cmake-4"; then + eqawarn "QA Notice: CMake 4 detected; building with -DCMAKE_POLICY_VERSION_MINIMUM=3.5" + eqawarn "This is merely a workaround and *not* a permanent fix." + cmakeargs+=( -DCMAKE_POLICY_VERSION_MINIMUM=3.5 ) + fi fi pushd "${BUILD_DIR}" > /dev/null || die From c61429856424975f5afc1d55d8f153fb3639ab18 Mon Sep 17 00:00:00 2001 From: Andreas Sturmlechner Date: Mon, 19 May 2025 20:37:02 +0200 Subject: [PATCH 3/4] cmake.eclass: Add CMAKE_QA_COMPAT_SKIP flag to skip compat checks Signed-off-by: Andreas Sturmlechner --- eclass/cmake.eclass | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/eclass/cmake.eclass b/eclass/cmake.eclass index b538af80a4b10..f327521e9fc1f 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 @@ -446,15 +452,17 @@ cmake_src_configure() { 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 ! [[ ${CMAKE_QA_COMPAT_SKIP} ]]; then + 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) + 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) + fi # Prepare Gentoo override rules (set valid compiler, append CPPFLAGS etc.) local build_rules=${BUILD_DIR}/gentoo_rules.cmake From 4a6845b4ff2f392f58173e5bc06415b824b8f1f4 Mon Sep 17 00:00:00 2001 From: Andreas Sturmlechner Date: Mon, 2 Jun 2025 23:08:16 +0200 Subject: [PATCH 4/4] profiles: Unmask dev-build/cmake-4 Bug: https://bugs.gentoo.org/951350 Signed-off-by: Andreas Sturmlechner --- profiles/package.mask | 4 ---- 1 file changed, 4 deletions(-) diff --git a/profiles/package.mask b/profiles/package.mask index f490fb1941921..4bd3ba2c6576c 100644 --- a/profiles/package.mask +++ b/profiles/package.mask @@ -263,10 +263,6 @@ dev-libs/libxml2-compat net-im/transwhat net-im/yowsup -# Sam James (2025-03-27) -# Large-scale breakage (bug #951350). -=dev-build/cmake-4* - # Michał Górny (2025-03-17) # Xfce 4.22 prereleases. Masked because they tend to be quite unstable. >=xfce-base/exo-4.21