cmake: add_llext_target: handle empty LLEXT_REMOVE_FLAGS

When LLEXT_REMOVE_FLAGS is empty, the regular expression that is
constructed to remove flags from the Zephyr flags would match any
string, resulting in all flags being removed. This is not the intended
behavior, so we need to handle this case by setting the regular
expression to a pattern that does not match anything.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
This commit is contained in:
Luca Burelli 2024-04-10 17:34:32 +02:00 committed by Alberto Escolar
parent 14509a8d7b
commit ad8b90ad36

View file

@ -5302,6 +5302,11 @@ function(add_llext_target target_name)
OUTPUT_VARIABLE llext_remove_flags_regexp
)
string(REPLACE ";" "|" llext_remove_flags_regexp "${llext_remove_flags_regexp}")
if ("${llext_remove_flags_regexp}" STREQUAL "")
# an empty regexp would match anything, we actually need the opposite
# so set it to match empty strings
set(llext_remove_flags_regexp "^$")
endif()
set(zephyr_flags
"$<TARGET_PROPERTY:zephyr_interface,INTERFACE_COMPILE_OPTIONS>"
)