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 164B71581B9 for ; Sun, 05 Oct 2025 21:50:14 +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 EE9DC340F79 for ; Sun, 05 Oct 2025 21:50:13 +0000 (UTC) Received: from bobolink.gentoo.org (localhost [127.0.0.1]) by bobolink.gentoo.org (Postfix) with ESMTP id 17768110374; Sun, 05 Oct 2025 21:50:11 +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 0ECC5110374 for ; Sun, 05 Oct 2025 21:50:11 +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 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id B5854340EA7 for ; Sun, 05 Oct 2025 21:50:10 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 22EDC34FA for ; Sun, 05 Oct 2025 21:50:09 +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: <1759700983.fade5bd1cfb710a8673bf3d9bc1d788df986236e.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: fade5bd1cfb710a8673bf3d9bc1d788df986236e X-VCS-Branch: master Date: Sun, 05 Oct 2025 21:50:09 +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: c91d58f0-67ec-4d0a-828d-fbf6beeb0c8c X-Archives-Hash: 277a7c63704688f7580e73f161c1e73b commit: fade5bd1cfb710a8673bf3d9bc1d788df986236e Author: Andreas Sturmlechner gentoo org> AuthorDate: Sun Sep 28 12:12:34 2025 +0000 Commit: Andreas Sturmlechner gentoo org> CommitDate: Sun Oct 5 21:49:43 2025 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=fade5bd1 cmake.eclass: Provide cmake_prepare() to solve conflicts w/ other eclass Split out what we need from cmake_src_prepare into new cmake_prepare(). cmake_src_prepare henceforth just calls default_src_prepare(), then cmake_prepare(). This change was made for >=EAPI-8 only. This also switches on a general EAPI=7 imminent error QA notice. Bug: https://bugs.gentoo.org/853805 Signed-off-by: Andreas Sturmlechner gentoo.org> eclass/cmake.eclass | 125 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 81 insertions(+), 44 deletions(-) diff --git a/eclass/cmake.eclass b/eclass/cmake.eclass index b3a1cde6057e..e3f9a50a518d 100644 --- a/eclass/cmake.eclass +++ b/eclass/cmake.eclass @@ -303,6 +303,8 @@ _cmake_check_build_dir() { if [[ ${EAPI} == 7 ]]; then : "${CMAKE_USE_DIR:=${S}}" else + # Since EAPI-8 we use current working directory, bug #704524 + # esp. test with 'special' pkgs like: app-arch/brotli, net-libs/quiche : "${CMAKE_USE_DIR:=${PWD}}" fi if [[ -n ${CMAKE_IN_SOURCE_BUILD} ]]; then @@ -394,22 +396,38 @@ _cmake_modify-cmakelists() { _EOF_ } -# @FUNCTION: cmake_src_prepare +# @FUNCTION: _cmake4_callout +# @INTERNAL # @DESCRIPTION: -# Apply ebuild and user patches. *MUST* be run or cmake_src_configure will fail. -cmake_src_prepare() { +# QA notice printout for build systems unsupported w/ CMake-4. +_cmake4_callout() { + if [[ ${_CMAKE_MINREQVER_UNSUPPORTED} ]]; 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 has_version -b ">=dev-build/cmake-4"; then + eqawarn "CMake 4 detected; building with -DCMAKE_POLICY_VERSION_MINIMUM=3.5" + eqawarn "This is merely a workaround and *not* a permanent fix." + fi + fi +} + +# @FUNCTION: cmake_prepare +# @DESCRIPTION: +# Check existence of and sanitise CMake files, then make ${CMAKE_USE_DIR} +# read-only. *MUST* be run or cmake_src_configure will fail. EAPI-8 only. +cmake_prepare() { debug-print-function ${FUNCNAME} "$@" if [[ ${EAPI} == 7 ]]; then - pushd "${S}" > /dev/null || die # workaround from cmake-utils - # in EAPI-8, we use current working directory instead, bug #704524 - # esp. test with 'special' pkgs like: app-arch/brotli, net-libs/quiche + eerror "${FUNCNAME} is EAPI-8 only. Call cmake_src_prepare instead." + die "FATAL: Forbidden function call." fi - _cmake_check_build_dir - default_src_prepare + _cmake_check_build_dir - # check if CMakeLists.txt exists and if not then die + # Check if CMakeLists.txt exists and if not then die if [[ ! -e ${CMAKE_USE_DIR}/CMakeLists.txt ]] ; then eerror "Unable to locate CMakeLists.txt under:" eerror "\"${CMAKE_USE_DIR}/CMakeLists.txt\"" @@ -417,54 +435,68 @@ cmake_src_prepare() { die "FATAL: Unable to find CMakeLists.txt" fi - local modules_list - if [[ ${EAPI} == 7 && $(declare -p CMAKE_REMOVE_MODULES_LIST) != "declare -a"* ]]; then - modules_list=( ${CMAKE_REMOVE_MODULES_LIST} ) - else - modules_list=( "${CMAKE_REMOVE_MODULES_LIST[@]}" ) - fi + local modules_list=( "${CMAKE_REMOVE_MODULES_LIST[@]}" ) local name for name in "${modules_list[@]}" ; do - if [[ ${EAPI} == 7 ]]; then - find "${S}" -name "${name}.cmake" -exec rm -v {} + || die - else - find -name "${name}.cmake" -exec rm -v {} + || die - fi + find -name "${name}.cmake" -exec rm -v {} + || die done # Remove dangerous things. _cmake_modify-cmakelists + _cmake4_callout - if [[ ${_CMAKE_MINREQVER_UNSUPPORTED} ]]; 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 has_version -b ">=dev-build/cmake-4"; then - eqawarn "CMake 4 detected; building with -DCMAKE_POLICY_VERSION_MINIMUM=3.5" - eqawarn "This is merely a workaround and *not* a permanent fix." - fi - if [[ ${EAPI} == 7 ]]; then - eqawarn "QA Notice: EAPI=7 detected; this package is now a prime last-rites target." - fi + # Make ${CMAKE_USE_DIR} read-only in order to detect broken build systems + if [[ ${CMAKE_QA_SRC_DIR_READONLY} && ! ${CMAKE_IN_SOURCE_BUILD} ]]; then + chmod -R a-w "${CMAKE_USE_DIR}" fi + _CMAKE_PREPARE_HAS_RUN=1 +} + +# @FUNCTION: cmake_src_prepare +# @DESCRIPTION: +# Apply ebuild and user patches via default_src_prepare. In case of +# conflict with another eclass' src_prepare phase, use cmake_prepare +# instead (EAPI-8 only). +# In EAPI-7, this phase *must* be run or cmake_src_configure will fail. +cmake_src_prepare() { + debug-print-function ${FUNCNAME} "$@" + if [[ ${EAPI} == 7 ]]; then + pushd "${S}" > /dev/null || die # workaround from cmake-utils + default_src_prepare + _cmake_check_build_dir + # check if CMakeLists.txt exists and if not then die + if [[ ! -e ${CMAKE_USE_DIR}/CMakeLists.txt ]] ; then + eerror "Unable to locate CMakeLists.txt under:" + eerror "\"${CMAKE_USE_DIR}/CMakeLists.txt\"" + eerror "Consider not inheriting the cmake eclass." + die "FATAL: Unable to find CMakeLists.txt" + fi + local modules_list + if [[ $(declare -p CMAKE_REMOVE_MODULES_LIST) != "declare -a"* ]]; then + modules_list=( ${CMAKE_REMOVE_MODULES_LIST} ) + else + modules_list=( "${CMAKE_REMOVE_MODULES_LIST[@]}" ) + fi + local name + for name in "${modules_list[@]}" ; do + find "${S}" -name "${name}.cmake" -exec rm -v {} + || die + done + _cmake_modify-cmakelists # Remove dangerous things. + _cmake4_callout popd > /dev/null || die - fi - - # Make ${CMAKE_USE_DIR} (in EAPI-7: ${S}) read-only in order to detect - # broken build systems. - if [[ ${CMAKE_QA_SRC_DIR_READONLY} && ! ${CMAKE_IN_SOURCE_BUILD} ]]; then - if [[ ${EAPI} == 7 ]]; then + # Make ${S} read-only in order to detect broken build systems + if [[ ${CMAKE_QA_SRC_DIR_READONLY} && ! ${CMAKE_IN_SOURCE_BUILD} ]]; then chmod -R a-w "${S}" - else - chmod -R a-w "${CMAKE_USE_DIR}" fi + _CMAKE_PREPARE_HAS_RUN=1 + eqawarn "QA Notice: cmake.eclass will throw unsupported EAPI=7 error after 2025-11-01." + else + default_src_prepare + cmake_prepare fi - - _CMAKE_SRC_PREPARE_HAS_RUN=1 } # @VARIABLE: MYCMAKEARGS @@ -490,8 +522,13 @@ cmake_src_prepare() { cmake_src_configure() { debug-print-function ${FUNCNAME} "$@" - [[ ${_CMAKE_SRC_PREPARE_HAS_RUN} ]] || \ - die "FATAL: cmake_src_prepare has not been run" + if [[ -z ${_CMAKE_PREPARE_HAS_RUN} ]]; then + if [[ ${EAPI} == 7 ]]; then + die "FATAL: cmake_src_prepare has not been run" + else + die "FATAL: cmake_src_prepare (or cmake_prepare) has not been run" + fi + fi _cmake_check_build_dir