From 3759d2bc463c92f71285bf6e11c8b7ca756869f5 Mon Sep 17 00:00:00 2001 From: Flatcar Buildbot Date: Mon, 3 Jul 2023 07:15:25 +0000 Subject: [PATCH] eclass/cmake: Sync with Gentoo It's from Gentoo commit b6e2235a3982cad4d74bb7eb49e858835344c3ba. --- .../portage-stable/eclass/cmake.eclass | 29 ++++++++++++------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/sdk_container/src/third_party/portage-stable/eclass/cmake.eclass b/sdk_container/src/third_party/portage-stable/eclass/cmake.eclass index 24787f1c2a..d70f2cbf1f 100644 --- a/sdk_container/src/third_party/portage-stable/eclass/cmake.eclass +++ b/sdk_container/src/third_party/portage-stable/eclass/cmake.eclass @@ -293,6 +293,15 @@ _cmake_check_build_dir() { BUILD_DIR="${CMAKE_USE_DIR}" else : "${BUILD_DIR:=${CMAKE_USE_DIR}_build}" + + # Avoid creating ${WORKDIR}_build (which is above WORKDIR). + # TODO: For EAPI > 8, we should ban S=WORKDIR for CMake. + # See bug #889420. + if [[ ${S} == "${WORKDIR}" && ${BUILD_DIR} == "${WORKDIR}_build" ]] ; then + eqawarn "QA notice: S=WORKDIR is deprecated for cmake.eclass." + eqawarn "Please relocate the sources in src_unpack." + BUILD_DIR="${WORKDIR}"/${P}_build + fi fi einfo "Source directory (CMAKE_USE_DIR): \"${CMAKE_USE_DIR}\"" @@ -484,17 +493,17 @@ cmake_src_configure() { cat >> "${toolchain_file}" <<- _EOF_ || die set(CMAKE_SYSTEM_NAME "${sysname}") _EOF_ + fi - if [ "${SYSROOT:-/}" != "/" ] ; then - # When cross-compiling with a sysroot (e.g. with crossdev's emerge wrappers) - # we need to tell cmake to use libs/headers from the sysroot but programs from / only. - cat >> "${toolchain_file}" <<- _EOF_ || die - set(CMAKE_SYSROOT "${ESYSROOT}") - set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) - set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) - set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) - _EOF_ - fi + if [[ ${SYSROOT:-/} != / ]] ; then + # When building with a sysroot (e.g. with crossdev's emerge wrappers) + # we need to tell cmake to use libs/headers from the sysroot but programs from / only. + cat >> "${toolchain_file}" <<- _EOF_ || die + set(CMAKE_SYSROOT "${ESYSROOT}") + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) + _EOF_ fi if use prefix-guest; then