Fix handling CC/CXX/FC values that contain three or more words by
splitting all multi-argument CC/CXX/FC into the executable name kept
in the variable, and additional options that are moved to CFLAGS,
CXXFLAGS or FCFLAGS appropriately.
---
 eclass/cmake-utils.eclass | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/eclass/cmake-utils.eclass b/eclass/cmake-utils.eclass
index 393ee28..2c41f6b 100644
--- a/eclass/cmake-utils.eclass
+++ b/eclass/cmake-utils.eclass
@@ -492,6 +492,21 @@ enable_cmake-utils_src_configure() {
 
        _cmake_check_build_dir
 
+       # Split CC/CXX/FC from multilib.eclass to be CMake-friendly, #542530
+       local myCC=( $(tc-getCC) )
+       local myCXX=( $(tc-getCXX) )
+       local myFC=( $(tc-getFC) )
+       local -x CC="${myCC[0]}" CXX="${myCXX[0]}" FC="${myFC[0]}"
+       [[ ${#myCC[@]} -gt 1 && ${myCC[1]} != -* ]] \
+               && die "CC contains non-relocatable option: ${myCC[*]:0:2} ..."
+       [[ ${#myCXX[@]} -gt 1 && ${myCXX[1]} != -* ]] \
+               && die "CXX contains non-relocatable option: ${myCXX[*]:0:2} 
..."
+       [[ ${#myFC[@]} -gt 1 && ${myFC[1]} != -* ]] \
+               && die "FC contains non-relocatable option: ${myFC[*]:0:2} ..."
+       local -x CFLAGS="${myCC[*]:1} ${CFLAGS}"
+       local -x CXXFLAGS="${myCXX[*]:1} ${CXXFLAGS}"
+       local -x FCFLAGS="${myFC[*]:1} ${FCFLAGS}"
+
        # Fix xdg collision with sandbox
        local -x XDG_CONFIG_HOME="${T}"
 
@@ -528,9 +543,9 @@ enable_cmake-utils_src_configure() {
 
        local toolchain_file=${BUILD_DIR}/gentoo_toolchain.cmake
        cat > ${toolchain_file} <<- _EOF_ || die
-               SET (CMAKE_C_COMPILER $(tc-getCC))
-               SET (CMAKE_CXX_COMPILER $(tc-getCXX))
-               SET (CMAKE_Fortran_COMPILER $(tc-getFC))
+               SET (CMAKE_C_COMPILER "${CC}")
+               SET (CMAKE_CXX_COMPILER "${CXX}")
+               SET (CMAKE_Fortran_COMPILER "${FC}")
        _EOF_
 
        if tc-is-cross-compiler; then
-- 
2.10.1


Reply via email to