From 6331dae62394d8206c7c71088c5b42a3b7ef2d2f Mon Sep 17 00:00:00 2001 From: Danny Oerndrup Date: Thu, 13 Jun 2019 15:33:03 +0200 Subject: [PATCH] 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 --- CMakeLists.txt | 4 +++- cmake/compiler/gcc/target_base.cmake | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2586821ca6c..ff30fb11cdc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -984,8 +984,10 @@ get_property(GKSF GLOBAL PROPERTY GENERATED_KERNEL_SOURCE_FILES) get_property(CSTD GLOBAL PROPERTY CSTD) set_ifndef(CSTD c99) +# @Intent: Obtain compiler specific flag for specifying the c standard +toolchain_cc_cstd_flag(CC_CSTD ${CSTD}) zephyr_compile_options( - $<$:-std=${CSTD}> + $<$:${CC_CSTD}> ) # @Intent: Configure linker scripts, i.e. generate linker scripts with variables substituted diff --git a/cmake/compiler/gcc/target_base.cmake b/cmake/compiler/gcc/target_base.cmake index 39146c40db6..b8f834ce491 100644 --- a/cmake/compiler/gcc/target_base.cmake +++ b/cmake/compiler/gcc/target_base.cmake @@ -12,3 +12,9 @@ macro(toolchain_cc_nocommon) zephyr_compile_options(-fno-common) endmacro() + +macro(toolchain_cc_cstd_flag dest_var_name c_std) + + set_ifndef(${dest_var_name} "-std=${c_std}") + +endmacro()