diff options
Diffstat (limited to 'eclass')
| -rw-r--r-- | eclass/cmake.eclass | 127 |
1 files changed, 83 insertions, 44 deletions
diff --git a/eclass/cmake.eclass b/eclass/cmake.eclass index 51bcb57653d..230bca97d09 100644 --- a/eclass/cmake.eclass +++ b/eclass/cmake.eclass @@ -220,6 +220,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 @@ -311,22 +313,41 @@ _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 + if [[ ${EAPI} == 7 ]]; then + eqawarn "QA Notice: EAPI=7 detected; this package is now a prime last-rites target." + 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, media-gfx/gmic, 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\"" @@ -334,54 +355,67 @@ 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 + else + default_src_prepare + cmake_prepare fi - - _CMAKE_SRC_PREPARE_HAS_RUN=1 } # @VARIABLE: MYCMAKEARGS @@ -407,8 +441,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 |
