Skip to content
This repository was archived by the owner on Apr 17, 2023. It is now read-only.
This repository was archived by the owner on Apr 17, 2023. It is now read-only.

Failing build when using 3rd Party libraries #17

@MrPointer

Description

@MrPointer

Originally reported by @machadolab in #15:

While troubleshooting, I also came across an issue with library naming. I have several popular arduino libs installed from Adafruit that have library names that do not conform to the arduino_compliant_library_name that Arduino-CMake-NG generates - for example Adafruit_NeoPixel and Adafruit_NeoMatrix are both converted to Adafruit_Neopixel and Adafruit_Neomatrix when the library directory is looked up.
The 3rd party library way did not work because the library uses arduino code and it looks like none of the arduino CFLAGs are passed to the building of the library. For example, I tried to define a user library for Adafruit_NeoPixel like so:

set(Adafruit_NeoPixel_Path /path/to/sketchbook/libraries/Adafruit_NeoPixel)
add_library(Adafruit_NeoPixel_lib STATIC ${Adafruit_NeoPixel_Path}/Adafruit_NeoPixel.cpp)
target_include_directories(Adafruit_NeoPixel_lib PUBLIC ${Adafruit_NeoPixel_Path})
link_arduino_library(Hello_World Adafruit_NeoPixel_lib ${board_id})

and get the build error:

In file included from /Users/machado/Dropbox/Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp:34:0:
/Users/machado/Dropbox/Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.h:25:23: fatal error: WProgram.h: No such file or directory
  #include <WProgram.h>
                       ^
compilation terminated.
make[3]: *** [CMakeFiles/Adafruit_NeoPixel_lib.dir/Users/machado/Dropbox/Arduino/libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp.obj] Error 1
make[2]: *** [CMakeFiles/Adafruit_NeoPixel_lib.dir/all] Error 2
make[1]: *** [CMakeFiles/Hello_World.dir/rule] Error 2
make: *** [Hello_World] Error 2

Because the define ARDUINO is not present and therefore it falls back to looking for WProgram.h.

To summarize, here's a list of the key issues:

  • Arduino-Compliant Name as suggested by the framework isn't really compliant and doesn't work in all cases - only for built-in libraries
  • It seems that User/Custom/3rd Party Libraries that resemble an Arduino Library don't inherit the build flags a typical Arduino library should have

Metadata

Metadata

Assignees

Labels

bugPotential bug in code

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions