summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoshua Watt <JPEWhacker@gmail.com>2020-07-21 17:52:11 (GMT)
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-07-31 21:02:52 (GMT)
commitaea80fa7d11a56a2d17458ce0f51fc3c8fc9a49b (patch)
tree545845081d8cb52139c3814c93a084ace8a8d0e1
parent579f1820be7af0f167e13f88bbd34d69745a5894 (diff)
downloadpoky-aea80fa7d11a56a2d17458ce0f51fc3c8fc9a49b.tar.gz
classes/cmake: Fix host detection
Fixes the class to use HOST_OS and HOST_ARCH to set the cmake SYSTEM variables. The HOST variables should be used instead of TARGET_OS/TARGET_ARCH because we want to control how cmake compiles for where the package is going to run (the host), not what it will be generating output for (the target). The distinction is only really relevant when building canadian cross recipes. Also fix up the host OS detection to account for MinGW by setting CMAKE_SYSTEM_NAME to "Windows". This eliminates the need for meta-mingw to patch this in all the cmake recipes it builds. (From OE-Core rev: 59b8c49a54b8977ba2f3ed4f33f0fd3f7dd749d5) Signed-off-by: Joshua Watt <JPEWhacker@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit 01245db2893e39ffb5d4a00e4689f048d0698974) Signed-off-by: Steve Sakoman <steve@sakoman.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes/cmake.bbclass19
1 files changed, 13 insertions, 6 deletions
diff --git a/meta/classes/cmake.bbclass b/meta/classes/cmake.bbclass
index 94ed806..8243f7c 100644
--- a/meta/classes/cmake.bbclass
+++ b/meta/classes/cmake.bbclass
@@ -70,15 +70,22 @@ CMAKE_BUILD_PARALLEL_LEVEL_task-install = "${@oe.utils.parallel_make(d, True)}"
70OECMAKE_TARGET_COMPILE ?= "all" 70OECMAKE_TARGET_COMPILE ?= "all"
71OECMAKE_TARGET_INSTALL ?= "install" 71OECMAKE_TARGET_INSTALL ?= "install"
72 72
73def map_host_os_to_system_name(host_os):
74 if host_os.startswith('mingw'):
75 return 'Windows'
76 if host_os.startswith('linux'):
77 return 'Linux'
78 return host_os
79
73# CMake expects target architectures in the format of uname(2), 80# CMake expects target architectures in the format of uname(2),
74# which do not always match TARGET_ARCH, so all the necessary 81# which do not always match TARGET_ARCH, so all the necessary
75# conversions should happen here. 82# conversions should happen here.
76def map_target_arch_to_uname_arch(target_arch): 83def map_host_arch_to_uname_arch(host_arch):
77 if target_arch == "powerpc": 84 if host_arch == "powerpc":
78 return "ppc" 85 return "ppc"
79 if target_arch == "powerpc64": 86 if host_arch == "powerpc64":
80 return "ppc64" 87 return "ppc64"
81 return target_arch 88 return host_arch
82 89
83cmake_do_generate_toolchain_file() { 90cmake_do_generate_toolchain_file() {
84 if [ "${BUILD_SYS}" = "${HOST_SYS}" ]; then 91 if [ "${BUILD_SYS}" = "${HOST_SYS}" ]; then
@@ -88,8 +95,8 @@ cmake_do_generate_toolchain_file() {
88# CMake system name must be something like "Linux". 95# CMake system name must be something like "Linux".
89# This is important for cross-compiling. 96# This is important for cross-compiling.
90$cmake_crosscompiling 97$cmake_crosscompiling
91set( CMAKE_SYSTEM_NAME `echo ${TARGET_OS} | sed -e 's/^./\u&/' -e 's/^\(Linux\).*/\1/'` ) 98set( CMAKE_SYSTEM_NAME ${@map_host_os_to_system_name(d.getVar('HOST_OS'))} )
92set( CMAKE_SYSTEM_PROCESSOR ${@map_target_arch_to_uname_arch(d.getVar('TARGET_ARCH'))} ) 99set( CMAKE_SYSTEM_PROCESSOR ${@map_host_arch_to_uname_arch(d.getVar('HOST_ARCH'))} )
93set( CMAKE_C_COMPILER ${OECMAKE_C_COMPILER} ) 100set( CMAKE_C_COMPILER ${OECMAKE_C_COMPILER} )
94set( CMAKE_CXX_COMPILER ${OECMAKE_CXX_COMPILER} ) 101set( CMAKE_CXX_COMPILER ${OECMAKE_CXX_COMPILER} )
95set( CMAKE_C_COMPILER_LAUNCHER ${OECMAKE_C_COMPILER_LAUNCHER} ) 102set( CMAKE_C_COMPILER_LAUNCHER ${OECMAKE_C_COMPILER_LAUNCHER} )