arduino-cmake
arduino-cmake copied to clipboard
REGEX in find_arduino_libraries doesn't match #includes with trailing spaces or comments
The result of this bug is needed dependencies are not included, resulting in compile errors.
I've only verified this when using the generate_arduino_example( ) syntax, but I expect it applies to other cases.
In short, if the myExample.ino file has an #include directive for an Arduino library header file and the directive has trailing whitespace or a trailing comment, the REGEX used in:
if("#${SRC_LINE}#" MATCHES "^#[ \t]*#[ \t]*include[ \t]*[<\"]([^>\"]*)[>\"]#")
does not match it, so that library doesn't get added to the includes.
A simple fix is to replace the line with:
if("#${SRC_LINE}#" MATCHES "^#[ \t]*#[ \t]*include[ \t]*[<\"]([^>\"]*)[>\"].*#")
This simple fix of appending .*
allows any trailing characters, so it doesn't enforce the language syntax, but that is fine. Arduino-cmake can take care of including the dependencies and the compiler can pick up syntax errors since users are accustomed to silly formatting errors that are caught by the compiler.