mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-01 10:40:47 +03:00
feat(cmakev2/utilities): add remove_duplicated_flags function
This function is primarily used by the toolchain files. Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
This commit is contained in:
@@ -473,3 +473,23 @@ function(__get_compile_options)
|
||||
endforeach()
|
||||
set(${ARG_OUTPUT} "${compile_options}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
#[[
|
||||
remove_duplicated_flags(<flags> <uniq_flags>)
|
||||
|
||||
:flags[in]: Input string with compilation flags.
|
||||
:uniq_flags[out]: Output string with unified compilation flags.
|
||||
|
||||
Remove duplicate entries from a string of compilation flags.
|
||||
#]]
|
||||
function(remove_duplicated_flags FLAGS UNIQFLAGS)
|
||||
set(FLAGS_LIST "${FLAGS}")
|
||||
# Convert the given flags, as a string, into a CMake list type
|
||||
separate_arguments(FLAGS_LIST)
|
||||
# Remove all the duplicated flags
|
||||
list(REMOVE_DUPLICATES FLAGS_LIST)
|
||||
# Convert the list back to a string
|
||||
string(REPLACE ";" " " FLAGS_LIST "${FLAGS_LIST}")
|
||||
# Return that string to the caller
|
||||
set(${UNIQFLAGS} "${FLAGS_LIST}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
Reference in New Issue
Block a user