@@ -839,10 +839,8 @@ endfunction()
839839# ----------------------------------------------------------------------------------------------------------------------
840840# Preprocesses the source files of `TARGET`, similar like arduino-cli would do.
841841# ----------------------------------------------------------------------------------------------------------------------
842- function (__arduino_preprocess_sketch TARGET OUTPUT_DIRPATH SOURCE_DIRPATH SOURCE_FILENAME) # [SOURCE_FILENAME...]
843- set (_source_list "${SOURCE_FILENAME} " ${ARGN} )
844-
845- set (_sketch_list ${_source_list} ) # <-------------------------------------------- collect sketches from _source_list
842+ function (__arduino_preprocess_sketch TARGET OUTPUT_DIRPATH SOURCE_DIRPATH SOURCES )
843+ set (_sketch_list ${SOURCES} ) # <------------------------------------------------------ collect sketches from SOURCES
846844 list (FILTER _sketch_list INCLUDE REGEX "${__ARDUINO_SKETCH_SUFFIX} " )
847845 list (PREPEND _sketch_list "${TARGET} .ino" )
848846 list (REMOVE_DUPLICATES _sketch_list)
@@ -853,9 +851,9 @@ function(__arduino_preprocess_sketch TARGET OUTPUT_DIRPATH SOURCE_DIRPATH SOURCE
853851
854852 target_sources ("${TARGET} " PUBLIC "${_preprocessed_filepath} " )
855853
856- list (REMOVE_ITEM _source_list ${_sketch_list} ) # <--------------------------------- preprocess regular/other sources
854+ list (REMOVE_ITEM SOURCES ${_sketch_list} ) # <----- --------------------------------- preprocess regular/other sources
857855
858- foreach (_filename IN LISTS _source_list )
856+ foreach (_filename IN LISTS SOURCES )
859857 __arduino_preprocess(
860858 _preprocessed_filepath "${OUTPUT_DIRPATH} "
861859 "${SOURCE_DIRPATH} " SOURCE "${_filename} " )
@@ -909,7 +907,7 @@ function(__arduino_toolchain_finalize DIRECTORY)
909907
910908 __arduino_preprocess_sketch( # <----------------------------------------------------------- build the sketch
911909 "${_target} " "${_sketch_dirpath} "
912- "${_source_dirpath} " ${_source_list} )
910+ "${_source_dirpath} " " ${_source_list} " )
913911
914912 target_link_libraries ("${_target} " PUBLIC Arduino::Core)
915913
0 commit comments