From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 1040C158176 for ; Thu, 16 Oct 2025 19:15:01 +0000 (UTC) Received: from lists.gentoo.org (bobolink.gentoo.org [140.211.166.189]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) (Authenticated sender: relay-lists.gentoo.org@gentoo.org) by smtp.gentoo.org (Postfix) with ESMTPSA id F03D23410CA for ; Thu, 16 Oct 2025 19:15:00 +0000 (UTC) Received: from bobolink.gentoo.org (localhost [127.0.0.1]) by bobolink.gentoo.org (Postfix) with ESMTP id CA786110574; Thu, 16 Oct 2025 19:14:51 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by bobolink.gentoo.org (Postfix) with ESMTPS id C06AC110574 for ; Thu, 16 Oct 2025 19:14:51 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 758D1340D8B for ; Thu, 16 Oct 2025 19:14:51 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id BE7A23B22 for ; Thu, 16 Oct 2025 19:14:48 +0000 (UTC) From: "Andreas Sturmlechner" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Andreas Sturmlechner" Message-ID: <1760642064.576dc3cc0f0f1c629caaf855e4781bf3c6c16f47.asturm@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/ X-VCS-Repository: repo/gentoo X-VCS-Files: eclass/cmake.eclass X-VCS-Directories: eclass/ X-VCS-Committer: asturm X-VCS-Committer-Name: Andreas Sturmlechner X-VCS-Revision: 576dc3cc0f0f1c629caaf855e4781bf3c6c16f47 X-VCS-Branch: master Date: Thu, 16 Oct 2025 19:14:48 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: c489c7ab-afcf-4660-aacc-5721b4a3c28f X-Archives-Hash: c284bde5b386c19bf6800e6d06783517 commit: 576dc3cc0f0f1c629caaf855e4781bf3c6c16f47 Author: Andreas Sturmlechner gentoo org> AuthorDate: Mon Oct 13 20:15:45 2025 +0000 Commit: Andreas Sturmlechner gentoo org> CommitDate: Thu Oct 16 19:14:24 2025 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=576dc3cc cmake.eclass: For ECM, check and warn about <3.16 CMake minimum version ECM (extra-cmake-modules) mostly concerns KDE but also several third party packages. ECM has been warning about that since ECM 5.100, which was released in Nov 2022. - New variable CMAKE_ECM_MODE (values: auto,true,false) If "auto", tries to detect use of find_package(ECM) in CMakeLists.txt Also use instead of _ECM_ECLASS check in cmake_src_configure to adjust gentoo_common_config.cmake for ECM settings independently of ecm.eclass - _cmake_minreqver-check(): Results are stored in new _CMAKE_MINREQVER_CMAKE316 array. - _cmake_minreqver-info(): Only the latest relevant warning is shown as eqawarn - and only prefixed as "QA Notice" if a preceding QA Notice didn't strike already. This means for a build system using ECM with detected <3.5 versions: - CMake < 3.5: QA notice with file listing - CMake < 3.10: *No* warning but file listing if array is non-empty - CMake < 3.16: Warning with file listing Signed-off-by: Andreas Sturmlechner gentoo.org> eclass/cmake.eclass | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 3 deletions(-) diff --git a/eclass/cmake.eclass b/eclass/cmake.eclass index 3535a95da4aa..df91ba0f4a0f 100644 --- a/eclass/cmake.eclass +++ b/eclass/cmake.eclass @@ -110,6 +110,15 @@ fi # The default is set to "yes" (enabled). : "${CMAKE_WARN_UNUSED_CLI:=yes}" +# @ECLASS_VARIABLE: CMAKE_ECM_MODE +# @DEFAULT_UNSET +# @DESCRIPTION: +# Default value is "auto", which means _cmake_modify-cmakelists will make an +# effort to detect find_package(ECM) in CMakeLists.txt. If set to true, make +# extra checks and add common config settings related to ECM (KDE Extra CMake +# Modules). If set to false, do nothing. +: "${CMAKE_ECM_MODE:=auto}" + # @ECLASS_VARIABLE: CMAKE_EXTRA_CACHE_FILE # @USER_VARIABLE # @DEFAULT_UNSET @@ -141,6 +150,15 @@ _CMAKE_MINREQVER_CMAKE305=() # already added to _CMAKE_MINREQVER_CMAKE305. _CMAKE_MINREQVER_CMAKE310=() +# @ECLASS_VARIABLE: _CMAKE_MINREQVER_CMAKE316 +# @DEFAULT_UNSET +# @DESCRIPTION: +# Internal array containing : tuples detected by +# _cmake_minreqver-check() for any CMakeLists.txt with cmake_minimum_required +# version lower than 3.16 (causes ECM warnings since 5.100), on top of those +# already added to _CMAKE_MINREQVER_CMAKE305 and _CMAKE_MINREQVER_CMAKE310. +_CMAKE_MINREQVER_CMAKE316=() + # @ECLASS_VARIABLE: CMAKE_QA_SRC_DIR_READONLY # @USER_VARIABLE # @DEFAULT_UNSET @@ -161,6 +179,14 @@ _CMAKE_MINREQVER_CMAKE310=() [[ ${WANT_CMAKE} ]] && die "WANT_CMAKE has been removed and is a no-op" [[ ${PREFIX} ]] && die "PREFIX has been removed and is a no-op" +case ${CMAKE_ECM_MODE} in + auto|true|false) ;; + *) + eerror "Unknown value for \${CMAKE_ECM_MODE}" + die "Value ${CMAKE_ECM_MODE} is not supported" + ;; +esac + case ${CMAKE_MAKEFILE_GENERATOR} in emake) BDEPEND="dev-build/make" @@ -377,6 +403,11 @@ _cmake_minreqver-check() { _CMAKE_MINREQVER_CMAKE310+=( "${file}":"${ver}" ) chk=0 fi + # we don't want duplicates that were already flagged + if [[ $chk != 0 ]] && ver_test "${ver}" -lt "3.16"; then + _CMAKE_MINREQVER_CMAKE316+=( "${file}":"${ver}" ) + chk=0 + fi fi return ${chk} } @@ -390,6 +421,8 @@ _cmake_minreqver-info() { local warnlvl [[ -n ${_CMAKE_MINREQVER_CMAKE305[@]} ]] && warnlvl=305 [[ -n ${_CMAKE_MINREQVER_CMAKE310[@]} ]] || [[ ${warnlvl} ]] && warnlvl=310 + [[ ${CMAKE_ECM_MODE} == true ]] && + { [[ -n ${_CMAKE_MINREQVER_CMAKE316[@]} ]] || [[ ${warnlvl} ]] } && warnlvl=316 local weak_qaw="QA Notice: " minreqver_qanotice() { @@ -405,13 +438,18 @@ _cmake_minreqver-info() { eqawarn "If not fixed in upstream's code repository, we should make sure they are aware." eqawarn "See also tracker bug #964405; check existing or file a new bug for this package." ;; + 316) + eqawarn "${weak_qaw}Compatibility w/ CMake < 3.16 will be removed in future ECM release." + eqawarn "If not fixed in upstream's code repository, we should make sure they are aware." + eqawarn "See also tracker bug #964407; check existing or file a new bug for this package." + ;; esac eqawarn weak_qaw="" # weak notice: no "QA Notice" starting with second call } + local info minreqver_listing() { - local info case ${1} in 305) eqawarn "The following CMakeLists.txt files are causing errors:" @@ -425,6 +463,13 @@ _cmake_minreqver-info() { eqawarn fi ;; + 316) + if [[ ${warnlvl} -ge 316 ]] && [[ -n ${_CMAKE_MINREQVER_CMAKE316[@]} ]]; then + eqawarn "The following CMakeLists.txt files are causing warnings:" + for info in ${_CMAKE_MINREQVER_CMAKE316[*]}; do eqawarn " ${info}"; done + eqawarn + fi + ;; esac } @@ -436,7 +481,7 @@ _cmake_minreqver-info() { # for warnings, we only want the latest relevant one, but list all flagged files if [[ ${warnlvl} -ge 310 ]]; then minreqver_qanotice ${warnlvl} - minreqver_listing 310 + for info in 310 316; do minreqver_listing ${info}; done fi if [[ ${warnlvl} ]]; then if [[ -n ${_CMAKE_MINREQVER_CMAKE305[@]} ]] && has_version -b ">=dev-build/cmake-4"; then @@ -477,6 +522,9 @@ _cmake_modify-cmakelists() { einfo "${mod_line:22:99}" done fi + if [[ ${CMAKE_ECM_MODE} == auto ]] && grep -Eq "\s*find_package\s*\(\s*ECM " "${file}"; then + CMAKE_ECM_MODE=true + fi # Detect unsupported minimum CMake versions unless CMAKE_QA_COMPAT_SKIP is set if ! [[ ${CMAKE_QA_COMPAT_SKIP} ]]; then _cmake_minreqver-check "${file#"${CMAKE_USE_DIR}/"}" @@ -725,7 +773,7 @@ cmake_src_configure() { set(CMAKE_LINK_WARNING_AS_ERROR OFF CACHE BOOL "") _EOF_ - if [[ -n ${_ECM_ECLASS} ]]; then + if [[ ${CMAKE_ECM_MODE} == true ]]; then cat >> ${common_config} <<- _EOF_ || die set(ECM_DISABLE_QMLPLUGINDUMP ON CACHE BOOL "") set(ECM_DISABLE_APPSTREAMTEST ON CACHE BOOL "")