cmake.bbclass: Set CMAKE_CROSSCOMPILING correctly

If CMAKE_SYSTEM_NAME is defined, CMake assumes we're cross-compiling,
which is not necessarily the case.

(From OE-Core rev: bd082c9be6191e67ea1b1bf10ce5e130a3433ab5)

Signed-off-by: Kyle Russell <bkylerussell@gmail.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Kyle Russell 2017-04-18 11:36:05 -04:00 committed by Richard Purdie
parent ae5d643114
commit 3b3aab0e8d
1 changed files with 4 additions and 0 deletions

View File

@ -42,9 +42,13 @@ def map_target_arch_to_uname_arch(target_arch):
return target_arch
cmake_do_generate_toolchain_file() {
if [ "${BUILD_SYS}" = "${HOST_SYS}" ]; then
CMAKE_CROSSCOMPILING="set( CMAKE_CROSSCOMPILING FALSE )"
fi
cat > ${WORKDIR}/toolchain.cmake <<EOF
# CMake system name must be something like "Linux".
# This is important for cross-compiling.
${CMAKE_CROSSCOMPILING}
set( CMAKE_SYSTEM_NAME `echo ${TARGET_OS} | sed -e 's/^./\u&/' -e 's/^\(Linux\).*/\1/'` )
set( CMAKE_SYSTEM_PROCESSOR ${@map_target_arch_to_uname_arch(d.getVar('TARGET_ARCH'))} )
set( CMAKE_C_COMPILER ${OECMAKE_C_COMPILER} )