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