Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,10 @@ The options are:
+--------------------+----------------------------------------------------------------------+------------------------------------+
| **LIBS** | Libraries to link *(sets up dependency tracking)* | |
+--------------------+----------------------------------------------------------------------+------------------------------------+
| **ARDLIBS** | Manual list of Arduino type libraries, common use case is when the | |
| | library header name does not match the librarie's directory name. | |
| | **ADVANCED OPTION!** Can be used in conjuction with **NO_AUTOLIBS**. | |
+--------------------+----------------------------------------------------------------------+------------------------------------+
| **NO_AUTOLIBS** | Disable Arduino library detection *(default On)* | |
+--------------------+----------------------------------------------------------------------+------------------------------------+
| **MANUAL** | Disable Arduino Core (enables pure AVR development) | |
Expand Down
23 changes: 12 additions & 11 deletions cmake/Platform/Arduino.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -361,10 +361,10 @@ endfunction()
function(GENERATE_ARDUINO_LIBRARY INPUT_NAME)
message(STATUS "Generating ${INPUT_NAME}")
parse_generator_arguments(${INPUT_NAME} INPUT
"NO_AUTOLIBS;MANUAL" # Options
"BOARD" # One Value Keywords
"SRCS;HDRS;LIBS" # Multi Value Keywords
${ARGN})
"NO_AUTOLIBS;MANUAL" # Options
"BOARD" # One Value Keywords
"SRCS;HDRS;LIBS;ARDLIBS" # Multi Value Keywords
${ARGN})

if(NOT INPUT_BOARD)
set(INPUT_BOARD ${ARDUINO_DEFAULT_BOARD})
Expand All @@ -373,22 +373,23 @@ function(GENERATE_ARDUINO_LIBRARY INPUT_NAME)
set(INPUT_MANUAL FALSE)
endif()
required_variables(VARS INPUT_SRCS INPUT_BOARD MSG "must define for target ${INPUT_NAME}")

set(ALL_LIBS)
set(ALL_SRCS ${INPUT_SRCS} ${INPUT_HDRS})

if(NOT INPUT_MANUAL)
setup_arduino_core(CORE_LIB ${INPUT_BOARD})
setup_arduino_core(CORE_LIB ${INPUT_BOARD})
endif()

find_arduino_libraries(TARGET_LIBS "${ALL_SRCS}" "")
set(LIB_DEP_INCLUDES)
find_arduino_libraries(TARGET_LIBS "${ALL_SRCS}" "${INPUT_ARDLIBS}")
foreach(LIB_DEP ${TARGET_LIBS})
set(LIB_DEP_INCLUDES "${LIB_DEP_INCLUDES} -I\"${LIB_DEP}\"")
arduino_debug_msg("Arduino Library: ${LIB_DEP}")
set(LIB_DEP_INCLUDES "${LIB_DEP_INCLUDES} -I\"${LIB_DEP}\" -I\"${LIB_DEP}/src\"")
endforeach()

if(NOT ${INPUT_NO_AUTOLIBS})
setup_arduino_libraries(ALL_LIBS ${INPUT_BOARD} "${ALL_SRCS}" "" "${LIB_DEP_INCLUDES}" "")
setup_arduino_libraries(ALL_LIBS ${INPUT_BOARD} "${ALL_SRCS}" "${INPUT_ARDLIBS}" "${LIB_DEP_INCLUDES}" "")
endif()

list(APPEND ALL_LIBS ${CORE_LIB} ${INPUT_LIBS})
Expand All @@ -398,8 +399,8 @@ function(GENERATE_ARDUINO_LIBRARY INPUT_NAME)
get_arduino_flags(ARDUINO_COMPILE_FLAGS ARDUINO_LINK_FLAGS ${INPUT_BOARD} ${INPUT_MANUAL})

set_target_properties(${INPUT_NAME} PROPERTIES
COMPILE_FLAGS "${ARDUINO_COMPILE_FLAGS} ${COMPILE_FLAGS} ${LIB_DEP_INCLUDES}"
LINK_FLAGS "${ARDUINO_LINK_FLAGS} ${LINK_FLAGS}")
COMPILE_FLAGS "${ARDUINO_COMPILE_FLAGS} ${COMPILE_FLAGS} ${LIB_DEP_INCLUDES}"
LINK_FLAGS "${ARDUINO_LINK_FLAGS} ${LINK_FLAGS}")

target_link_libraries(${INPUT_NAME} ${ALL_LIBS} "-lc -lm")
endfunction()
Expand Down