cmake.bbclass: Rework compiler program variables for allarch

CMake projects can specify the NONE project type. Projects that do this
do not use any C or C++ compiler, this currently works fine with caveat
that when changing the machine/arch the compiler is different causing
signature hash differences.

To avoid the signature hash differences clear the associated C/CXX
compiler variables. In order to achieve this with overrides, simplify
the existing construction of the values using a python function and
variable setting and remove the anonymous variable setup.

(From OE-Core rev: e0657ff13453deedbdcf7c2f8a8854f601c659bd)

Signed-off-by: Nathan Rossi <nathan@nathanrossi.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Nathan Rossi
2020-08-08 12:08:43 +00:00
committed by Richard Purdie
parent e4f6ea6811
commit 9e2c0e57df

View File

@@ -21,23 +21,6 @@ python() {
d.setVarFlag("do_compile", "progress", r"outof:^\[(\d+)/(\d+)\]\s+")
else:
bb.fatal("Unknown CMake Generator %s" % generator)
# C/C++ Compiler (without cpu arch/tune arguments)
if not d.getVar('OECMAKE_C_COMPILER'):
cc_list = d.getVar('CC').split()
if cc_list[0] == 'ccache':
d.setVar('OECMAKE_C_COMPILER_LAUNCHER', cc_list[0])
d.setVar('OECMAKE_C_COMPILER', cc_list[1])
else:
d.setVar('OECMAKE_C_COMPILER', cc_list[0])
if not d.getVar('OECMAKE_CXX_COMPILER'):
cxx_list = d.getVar('CXX').split()
if cxx_list[0] == 'ccache':
d.setVar('OECMAKE_CXX_COMPILER_LAUNCHER', cxx_list[0])
d.setVar('OECMAKE_CXX_COMPILER', cxx_list[1])
else:
d.setVar('OECMAKE_CXX_COMPILER', cxx_list[0])
}
OECMAKE_AR ?= "${AR}"
@@ -51,8 +34,23 @@ OECMAKE_CXX_LINK_FLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} ${CXXFLAGS} ${LD
CXXFLAGS += "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS}"
CFLAGS += "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS}"
OECMAKE_C_COMPILER_LAUNCHER ?= ""
OECMAKE_CXX_COMPILER_LAUNCHER ?= ""
def oecmake_map_compiler(compiler, d):
args = d.getVar(compiler).split()
if args[0] == "ccache":
return args[1], args[0]
return args[0], ""
# C/C++ Compiler (without cpu arch/tune arguments)
OECMAKE_C_COMPILER ?= "${@oecmake_map_compiler('CC', d)[0]}"
OECMAKE_C_COMPILER_LAUNCHER ?= "${@oecmake_map_compiler('CC', d)[1]}"
OECMAKE_CXX_COMPILER ?= "${@oecmake_map_compiler('CXX', d)[0]}"
OECMAKE_CXX_COMPILER_LAUNCHER ?= "${@oecmake_map_compiler('CXX', d)[1]}"
# clear compiler vars for allarch to avoid sig hash difference
OECMAKE_C_COMPILER_allarch = ""
OECMAKE_C_COMPILER_LAUNCHER_allarch = ""
OECMAKE_CXX_COMPILER_allarch = ""
OECMAKE_CXX_COMPILER_LAUNCHER_allarch = ""
OECMAKE_RPATH ?= ""
OECMAKE_PERLNATIVE_DIR ??= ""