a9183756-gh / Arduino-CMake-Toolchain

CMake toolchain for all Arduino compatible boards
MIT License
135 stars 40 forks source link

Simplify linking of custom Arduino libraries #41

Open a9183756-gh opened 3 years ago

a9183756-gh commented 3 years ago

If a custom arduino library is added using add_custom_arduino_library or add_custom_arduino_core, then all the targets, within the directory tree, link with that custom arduino library. Earlier mechanism, which is still supported, required explicit linking and was inflexible and confusing especially when some arduino libraries are linked automatically.

Example: add_custom_arduino_core(my_core)

If the following linking happens within the current cmake

# directory tree, then my_target links with my_core, instead of
# the inbuilt core.
target_link_arduino_libraries(my_target core)

In future, an explicit scoping mechanism for the custom libraries may be provided (SCOPE_LOCAL, SCOPE_GLOBAL, SCOPE_TREE). The default scope is SCOPE_TREE (which is the current behaviour in this patch).