summaryrefslogtreecommitdiff
path: root/eclass/cmake.eclass
AgeCommit message (Collapse)Author
2025-11-16cmake.eclass: Introduce cmake_prepare-per-cmakelistsAndreas Sturmlechner
Override this to be provided with a hook into the cmake_src_prepare loop over all CMakeLists.txt below CMAKE_USE_DIR. Will be called from inside that loop with <path-to-current-CMakeLists.txt> as single argument. Used for recursive CMakeLists.txt detections and modifications. Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
2025-11-13cmake.eclass: Add warning for installed CMake modules w/ <3.10 minimumAndreas Sturmlechner
These are even more important, as they can break any number of revdeps. Deduplicate _cmake_minreqver-info() and reuse it from src_install(). Properly fixes 4e35968ea53138d8b2726f8f2b9b1804dc291767. Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
2025-11-13cmake.eclass: Simplify _cmake_minreqver_check into _cmake_minreqver-getAndreas Sturmlechner
The original function was convoluted and simply did too much. Make it reusable by having it do exactly one thing and deal with the results from the calling function. The refactoring pays for itself by losing 18 lines. Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
2025-11-11cmake.eclass: Improve cmake_comment_add_subdirectory, fix min arg checkAndreas Sturmlechner
Thanks-to: Zurab Kvachadze <zurabid2016@gmail.com> Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
2025-11-11cmake.eclass: Wipe default optimization flags unconditionallyAndreas Sturmlechner
Mark CMAKE_BUILD_TYPE=Gentoo as no-op. This was obsolete a long time ago, the last two ebuilds setting it in ::gentoo were not using it for that purpose either and were since fixed. Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
2025-11-11cmake.eclass: cmake_comment_add_subdirectory: optionally accept "-f <path>"Andreas Sturmlechner
New function description: Comment out one or more add_subdirectory calls with #DONOTBUILD in a) a given file path (error out on nonexisting path) b) a CMakeLists.txt file inside a given directory (ewarn if not found) c) CMakeLists.txt in current directory (do nothing if not found). c) is unchanged prior behaviour. Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
2025-10-30cmake.eclass: Drop EAPI-7 supportAndreas Sturmlechner
Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
2025-10-30cmake.eclass: add global-scope ewarn for deprecated < EAPI 7Andreas Sturmlechner
Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
2025-10-27cmake.eclass: Drop ECM related initial-cache vars, moved to ecm.eclassAndreas Sturmlechner
Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
2025-10-21cmake.eclass: _cmake_minreqver-info(): Add missing semicolonAndreas Sturmlechner
Thanks-to: Arisu Tachibana <alicef@gentoo.org> Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
2025-10-19cmake.eclass: _cmake_modify-cmakelists(): Fix _cmake_minreqver-check callAndreas Sturmlechner
_cmake_minreqver-check may be called from any phase, so <file> path must be absolute. As a quick fix, push the path mangling into the output function _cmake_minreqver-info which (currently) is only called from cmake_prepare. Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
2025-10-16cmake.eclass: Add bug tracker info to CMake minreqver warningsAndreas Sturmlechner
Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
2025-10-15cmake.eclass: Tweak _cmake_minreqver-info() some moreAndreas Sturmlechner
Move "CMake 4 detected" message around, with bigger file listings, and logically, it is better placed at the end, before the upstream policy changes research link. Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
2025-10-15cmake.eclass: _cmake_minreqver-info(): Warn only on highest flagged levelAndreas Sturmlechner
Print "QA Notice" only on first (highest priority) warning, but still show the relevant message. Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
2025-10-15cmake.eclass: For ECM, check and warn about <3.16 CMake minimum versionAndreas Sturmlechner
- New variable CMAKE_ECM_MODE (values: auto,true,false) Also use instead of _ECM_ECLASS check in cmake_src_configure - _cmake_minreqver-check(): Results are stored in new _CMAKE_MINREQVER_CMAKE316 array. - _cmake_minreqver-info(): Dump _CMAKE_MINREQVER_CMAKE316 array as eqawarn Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
2025-10-15cmake.eclass: Check and warn about <3.10 CMake minimum versionsAndreas Sturmlechner
- _cmake_minreqver-check(): Results are stored in new _CMAKE_MINREQVER_CMAKE310 array. - _cmake_minreqver-info(): Dump _CMAKE_MINREQVER_CMAKE310 array as eqawarn Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
2025-10-15cmake.eclass: No -DCMAKE_POLICY_VERSION_MINIMUM=3.5 w/ CMAKE_QA_COMPAT_SKIPAndreas Sturmlechner
If QA checks are skipped, then it is counterproductive to hide resulting errors. Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
2025-10-14cmake.eclass: cmake4_callout() -> _cmake_minreqver-info()Andreas Sturmlechner
- Dump _CMAKE_MINREQVER_CMAKE305 array as eqawarn message - CMake 4 workaround warning resharpening Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
2025-10-14cmake.eclass: _cmake_minreqver-lt() -> _cmake_minreqver-check()Andreas Sturmlechner
- Prepare for future cmake_minimum_version checks - Function now optionally takes one or two args: <file>: runs all version checks over <file> <file> <version>: only checks <version> against <file> - _CMAKE_MINREQVER_UNSUPPORTED is gone - _CMAKE_MINREQVER_CMAKE305 is empty (package "passed") or contains a list of <file>:<version> tuples Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
2025-10-13cmake.eclass: Set CMAKE_POLICY_DEFAULT_CMP0094=NEW to fix FindPythonAndreas Sturmlechner
See also: https://cmake.org/cmake/help/latest/policy/CMP0094.html Bug: https://bugs.gentoo.org/959154 Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
2025-10-09cmake.eclass: set -DCMAKE_LINK_WARNING_AS_ERROR=OFFSam James
As we already do for compiler -Werror. Bug: https://bugs.gentoo.org/963830 Signed-off-by: Sam James <sam@gentoo.org>
2025-10-07cmake.eclass: Raise dev-build/cmake minimum to 3.31.9-r1Andreas Sturmlechner
Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
2025-10-05cmake.eclass: Raise minimum dev-build/cmake version to 3.28.5Andreas Sturmlechner
Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
2025-10-05cmake.eclass: Update CMAKE_WARN_UNUSED_CLI default value descriptionPetr Vaněk
This commit updates the CMAKE_WARN_UNUSED_CLI variable description to accurately reflect the default value set to "yes". The CMAKE_WARN_UNUSED_CLI default value was changed to "yes" in cmake-utils.eclass in commit 3600c714eb86 ("cmake-utils.eclass: enable CMAKE_WARN_UNUSED_CLI for EAPI 6"), but the description did not reflect it. This description was later reused in the new cmake.eclass [1] without reflecting the default value either. Fixes: 9053737a4e16 ("cmake.eclass: New eclass, EAPI-7 only cleanup of cmake-utils") [1] Signed-off-by: Petr Vaněk <arkamar@gentoo.org> Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
2025-10-05cmake.eclass: disable automagic LTOSam James
Pass -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=OFF to avoid automagically enabling LTO if the compiler supports it. Note that unlike what we do w/ meson.eclass, we can't do some magic with `tc-is-lto` here because CMake doesn't allow refining the parallelism used. But that's fine. This change still allows using LTO via *FLAGS which is what we tell people to do. Bug: https://bugs.gentoo.org/927157 Signed-off-by: Sam James <sam@gentoo.org>
2025-10-02cmake.eclass: Really warn all EAPI-7 consumers that support will be droppedAndreas Sturmlechner
... after 2025-11-01. Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
2025-09-30cmake.eclass: fix pms violationPaul Zander
Escape sequences are not allowed for `die`, use eerror instead. Signed-off-by: Paul Zander <negril.nx+gentoo@gmail.com> Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
2025-09-30cmake.eclass: allow nonfatal cmake_src_testAlfred Wingate
This is already expected in tree via virtx use. $ qgrep 'virtx cmake_src_test' | wc -l 57 Bug: https://bugs.gentoo.org/961929 Closes: https://github.com/gentoo/gentoo/pull/40307 Signed-off-by: Alfred Wingate <parona@protonmail.com> Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
2025-09-30cmake.eclass: Provide cmake_prepare() to solve conflicts w/ other eclassAndreas Sturmlechner
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. Bug: https://bugs.gentoo.org/853805 Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
2025-09-27cmake.eclass: Reorder arguments in cmake_src_install cmake_build callAndreas Sturmlechner
Bug: https://bugs.gentoo.org/963428 Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
2025-06-24cmake.eclass: Avoid false positives by ensuring we find a function callAndreas Sturmlechner
Otherwise the regex might pick up a query of the resulting version var, e.g.: > if(CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 2.8.12) Bug: https://bugs.gentoo.org/958923 Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
2025-06-14cmake.eclass: Add src_install() check for CMake-4-incompatible modulesAndreas Sturmlechner
See examples: https://bugs.gentoo.org/953075 https://bugs.gentoo.org/957670 https://bugs.gentoo.org/957671 https://bugs.gentoo.org/957803 Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
2025-06-14cmake.eclass: Avoid none-detection by ensuring match starts w/ digitAndreas Sturmlechner
Thanks-to: Ionen Wolkens <ionen@gentoo.org> Closes: https://bugs.gentoo.org/957990 Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
2025-06-14cmake.eclass: mv _CMAKE_MINREQVER_UNSUPPORTED detection to src_prepareAndreas Sturmlechner
- _cmake_minverreq-lt(): New function for reusability of regex - Optimise #1: Reuse existing loop over CMakeLists.txt files - Optimise #2: If _CMAKE_MINREQVER_UNSUPPORTED is already set, then no further run of _cmake_minverreq-lt is necessary since we currently throw away the info on affected files - Relegate "CMake 4 detected; ..." to be a non-QA Notice, it is just an addendum Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
2025-06-13cmake.eclass: Introduce _CMAKE_MINREQVER_UNSUPPORTEDAndreas Sturmlechner
Allows to split detection/eqawarn and applying cmakearg over different phases. Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
2025-06-06cmake.eclass: quote "${file}" for sedsSam James
Otherwise sed may fail (as it can't find the files) on directories/files with spaces in the path, as is the case in dev-build/cmake itself where it'll die in src_prepare. Signed-off-by: Sam James <sam@gentoo.org>
2025-06-04cmake.eclass: _cmake_modify-cmakelists(): Consolidate the sedAndreas Sturmlechner
See also: https://github.com/gentoo/kde/pull/1046#pullrequestreview-2897140501 Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
2025-06-04cmake.eclass: Improve _cmake_modify-cmakelists()Andreas Sturmlechner
50% less find 50% less grep 100% less cut Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
2025-06-03cmake.eclass: Use get_makeopts_{jobs,loadavg}Michał Górny
See also: https://github.com/gentoo/gentoo/pull/39544 Signed-off-by: Michał Górny <mgorny@gentoo.org> Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
2025-06-03cmake.eclass: Permit overriding CTEST_{JOBS,LOADAVG}Michał Górny
Bug: https://bugs.gentoo.org/945081 Signed-off-by: Michał Górny <mgorny@gentoo.org> Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
2025-06-02cmake.eclass: CMake 4 QA check: Make sed case-insensitiveAndreas Sturmlechner
Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
2025-05-22cmake.eclass: EAPI=7: Extra slap on wristAndreas Sturmlechner
Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
2025-05-22cmake.eclass: CMake 4 QA notice: Use more wordsAndreas Sturmlechner
Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
2025-05-21cmake.eclass: CMake 4 QA check: Exit after first matchAndreas Sturmlechner
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: Michał Górny <mgorny@gentoo.org> Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
2025-05-21cmake.eclass: CMake 4 QA check: Apparently, cmake allows double-dotsAndreas Sturmlechner
As a quick fix, for now, don't error out on that. > ERROR: media-gfx/darktable-5.0.1-r2::gentoo failed (configure phase): > __eapi7_ver_compare: invalid version: 3.12..16 See also: > LibRaw-cmake/CMakeLists.txt:cmake_minimum_required(VERSION 3.12..16) Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
2025-05-20cmake.eclass: Add CMAKE_QA_COMPAT_SKIP flag to skip compat checksAndreas Sturmlechner
Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
2025-05-20cmake.eclass: If CMake 4 is detected, build w/ compat cmake argAndreas Sturmlechner
-DCMAKE_POLICY_VERSION_MINIMUM=3.5 Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
2025-05-20cmake.eclass: Add recursive CMakeLists.txt unsupported version detectionAndreas Sturmlechner
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>
2025-04-23cmake.eclass: use 'QA Notice:' prefix in eqawarnSam James
This makes life easier for tinderboxes, but we should improve this in some future EAPI. Signed-off-by: Sam James <sam@gentoo.org>
2025-02-03eclass: Say belated happy new year as wellAndreas Sturmlechner
Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>