1# SPDX-License-Identifier: Apache-2.0 2 3foreach(extra_flags EXTRA_CPPFLAGS EXTRA_LDFLAGS EXTRA_CFLAGS EXTRA_CXXFLAGS EXTRA_AFLAGS) 4 # Note: zephyr_get MERGE should not be used until issue #43959 is resolved. 5 zephyr_get(${extra_flags}) 6 list(LENGTH ${extra_flags} flags_length) 7 if(flags_length LESS_EQUAL 1) 8 # A length of zero means no argument. 9 # A length of one means a single argument or a space separated list was provided. 10 # In both cases, it is safe to do a separate_arguments on the argument. 11 separate_arguments(${extra_flags}_AS_LIST UNIX_COMMAND ${${extra_flags}}) 12 else() 13 # Already a proper list, no conversion needed. 14 set(${extra_flags}_AS_LIST "${${extra_flags}}") 15 endif() 16endforeach() 17 18if(EXTRA_CPPFLAGS) 19 zephyr_compile_options(${EXTRA_CPPFLAGS_AS_LIST}) 20endif() 21if(EXTRA_LDFLAGS) 22 zephyr_link_libraries(${EXTRA_LDFLAGS_AS_LIST}) 23endif() 24if(EXTRA_CFLAGS) 25 foreach(F ${EXTRA_CFLAGS_AS_LIST}) 26 zephyr_compile_options($<$<COMPILE_LANGUAGE:C>:${F}>) 27 endforeach() 28endif() 29if(EXTRA_CXXFLAGS) 30 foreach(F ${EXTRA_CXXFLAGS_AS_LIST}) 31 zephyr_compile_options($<$<COMPILE_LANGUAGE:CXX>:${F}>) 32 endforeach() 33endif() 34if(EXTRA_AFLAGS) 35 foreach(F ${EXTRA_AFLAGS_AS_LIST}) 36 zephyr_compile_options($<$<COMPILE_LANGUAGE:ASM>:${F}>) 37 endforeach() 38endif() 39