cmake: Toolchain abstraction: Introducing macro toolchain_cc_cstd_flag
The macro obtains the toolchain specific flag and value for setting of the requested c standard. The intent here is to abstract Zephyr's dependence on toolchains, thus allowing for easier porting to other, perhaps commercial, toolchains and/or usecases. No functional change expected. Signed-off-by: Danny Oerndrup <daor@demant.com>
This commit is contained in:
parent
d0d963a85d
commit
6331dae623
2 changed files with 9 additions and 1 deletions
|
@ -984,8 +984,10 @@ get_property(GKSF GLOBAL PROPERTY GENERATED_KERNEL_SOURCE_FILES)
|
||||||
get_property(CSTD GLOBAL PROPERTY CSTD)
|
get_property(CSTD GLOBAL PROPERTY CSTD)
|
||||||
set_ifndef(CSTD c99)
|
set_ifndef(CSTD c99)
|
||||||
|
|
||||||
|
# @Intent: Obtain compiler specific flag for specifying the c standard
|
||||||
|
toolchain_cc_cstd_flag(CC_CSTD ${CSTD})
|
||||||
zephyr_compile_options(
|
zephyr_compile_options(
|
||||||
$<$<COMPILE_LANGUAGE:C>:-std=${CSTD}>
|
$<$<COMPILE_LANGUAGE:C>:${CC_CSTD}>
|
||||||
)
|
)
|
||||||
|
|
||||||
# @Intent: Configure linker scripts, i.e. generate linker scripts with variables substituted
|
# @Intent: Configure linker scripts, i.e. generate linker scripts with variables substituted
|
||||||
|
|
|
@ -12,3 +12,9 @@ macro(toolchain_cc_nocommon)
|
||||||
zephyr_compile_options(-fno-common)
|
zephyr_compile_options(-fno-common)
|
||||||
|
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
|
macro(toolchain_cc_cstd_flag dest_var_name c_std)
|
||||||
|
|
||||||
|
set_ifndef(${dest_var_name} "-std=${c_std}")
|
||||||
|
|
||||||
|
endmacro()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue