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()