[PATCH 5/6] cmake.eclass: For ECM, check and warn about <3.16 CMake minimum version
- 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 <[email protected]> --- eclass/cmake.eclass | 54 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/eclass/cmake.eclass b/eclass/cmake.eclass index fca6494063..c2748137a0 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 @@ -140,6 +149,14 @@ _CMAKE_MINREQVER_CMAKE305=() # version lower than 3.10 (causes CMake warnings as of 4.0). _CMAKE_MINREQVER_CMAKE310=() +# @ECLASS_VARIABLE: _CMAKE_MINREQVER_CMAKE316 +# @DEFAULT_UNSET +# @DESCRIPTION: +# Internal array containing <file>:<version> 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). +_CMAKE_MINREQVER_CMAKE316=() + # @ECLASS_VARIABLE: CMAKE_QA_SRC_DIR_READONLY # @USER_VARIABLE # @DEFAULT_UNSET @@ -153,6 +170,14 @@ _CMAKE_MINREQVER_CMAKE310=() # @DESCRIPTION: # Array of tests that should be skipped when running CTest. +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" @@ -293,6 +318,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} } @@ -323,6 +353,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}/"}" @@ -352,7 +385,8 @@ _cmake_modify-cmakelists() { # cmake_minimum_required versions lower than supported or deprecated by CMake 4. _cmake_minreqver-info() { if [[ -z ${_CMAKE_MINREQVER_CMAKE305[@]} ]] && - [[ -z ${_CMAKE_MINREQVER_CMAKE310[@]} ]]; then + [[ -z ${_CMAKE_MINREQVER_CMAKE310[@]} ]] && + [[ -z ${_CMAKE_MINREQVER_CMAKE316[@]} ]]; then return fi local info @@ -387,6 +421,22 @@ _cmake_minreqver-info() { eqawarn fi fi + if [[ ${CMAKE_ECM_MODE} == true ]]; then + if [[ -n ${_CMAKE_MINREQVER_CMAKE305[@]} ]] || + [[ -n ${_CMAKE_MINREQVER_CMAKE310[@]} ]] || + [[ -n ${_CMAKE_MINREQVER_CMAKE316[@]} ]]; then + eqawarn "QA Notice: 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 + if [[ -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 + fi + fi eqawarn "An upstreamable patch should take any resulting CMake policy changes" eqawarn "into account. See also:" eqawarn " https://cmake.org/cmake/help/latest/manual/cmake-policies.7.html" @@ -619,7 +669,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 "") -- 2.51.0
signature.asc
Description: This is a digitally signed message part.
