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

3rd Party Libraries

Timor Gruber edited this page Oct 2, 2018 · 1 revision

These libraries also conform to the Arduino library-standard, but they're not part of the SDK. As such, they are also called "Arduino Libraries", just like built-in libraries.
They should generally include the library.properties file under their root directory (although not all of them do) and provide sources.

They are usually located under Arduino IDE's Sketchbook Path if they were downloaded with the Library Manager tool that comes built-into the Arduino IDE. If not, they can be located at any path.

As well as Built-in Libraries, they should first be found and then linked to another target.

The Arduino-CMake framework renames every given Arduino Library name to an Arduino-Compliant name, which is PascalCase.
However, 3rd Party libraries don't always conform to this naming standard (e.g the Adafruit_NeoPixel library), which creates an invalid symbol to search for the framework.
In order to avoid this behavior, one should pass the 3RD_PARTY option to the find_arduino_library function.

For example, to use the Adafruit_NeoPixel library we should do the following:

find_arduino_library(neoPixel Adafruit_NeoPixel ${board_id} 3RD_PARTY)
link_arduino_library(my_target neoPixel ${board_id})

Note that the example above assumes the my_target target has already been created earlier.
Also, board's ID has been retrieved as well.

Manual Addition

Another way to use 3rd Party libraries is to manually specify its sources.
What's really good with this approach is that it allows those libraries to be located anywhere in the system!
The downside? It probably means it can't be found using find_arduino_library.
Nevertheless, in order to use this approach, one should call the add_arduino_library function.

For example, to manually add the Adafruit_NeoPixel library discussed above we should do the following:

add_arduino_library(neoPixel ${board_id} custom_dir/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp)
link_arduino_library(my_target neoPixel ${board_id})

Note that the example above assumes the my_target target has already been created earlier and the board's ID has been retrieved as well.
Besides, the Adafruit_NeoPixel library resides under "non-locatable" directory named custom_dir, relative to the project's source directory.