From 065572bdc5985f3a481348fb69e0780ee2f7d7ba Mon Sep 17 00:00:00 2001 From: Raul E Rangel Date: Wed, 19 Apr 2023 15:54:01 -0600 Subject: cmake.eclass: Set CMAKE_SYSROOT when building with SYSROOT= When performing a SYSROOT= build, the --sysroot parameter was not getting passed to the compiler if the CBUILD and CHOST matched. This results in the build attempting to use BROOT libraries and headers instead of the ones from the SYSROOT. This change will allow `llvm` to be built into a new SYSROOT. ROOT=/build/amd64-host emerge sys-devel/llvm Signed-off-by: Raul E Rangel Closes: https://github.com/gentoo/gentoo/pull/30658 Signed-off-by: James Le Cuirot Signed-off-by: Andreas Sturmlechner --- eclass/cmake.eclass | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'eclass/cmake.eclass') diff --git a/eclass/cmake.eclass b/eclass/cmake.eclass index b7db941bfb2..340645e917b 100644 --- a/eclass/cmake.eclass +++ b/eclass/cmake.eclass @@ -407,17 +407,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 -- cgit v1.2.3