Update arduino-cmake
This commit is contained in:
parent
dcd5298323
commit
2c9e632873
@ -8,7 +8,7 @@ project(WeatherStation C CXX)
|
|||||||
|
|
||||||
set(ARDUINO_DEFAULT_BOARD uno)
|
set(ARDUINO_DEFAULT_BOARD uno)
|
||||||
set(ARDUINO_DEFAULT_PORT /dev/ttyUSB0)
|
set(ARDUINO_DEFAULT_PORT /dev/ttyUSB0)
|
||||||
set(ARDUINO_DEFAULT_SERIAL "picocom @INPUT_PORT@ -b 9600 -l")
|
set(ARDUINO_DEFAULT_SERIAL picocom @SERIAL_PORT@ -b 9600 -l)
|
||||||
|
|
||||||
#link_directories(${CMAKE_CURRENT_SOURCE_DIR}/../libraries)
|
#link_directories(${CMAKE_CURRENT_SOURCE_DIR}/../libraries)
|
||||||
|
|
||||||
|
@ -9,7 +9,8 @@
|
|||||||
# [SERIAL serial_cmd]
|
# [SERIAL serial_cmd]
|
||||||
# [PROGRAMMER programmer_id]
|
# [PROGRAMMER programmer_id]
|
||||||
# [AFLAGS flags]
|
# [AFLAGS flags]
|
||||||
# [NO_AUTOLIBS])
|
# [NO_AUTOLIBS]
|
||||||
|
# [MANUAL])
|
||||||
#=============================================================================#
|
#=============================================================================#
|
||||||
#
|
#
|
||||||
# generaters firmware and libraries for Arduino devices
|
# generaters firmware and libraries for Arduino devices
|
||||||
@ -27,6 +28,7 @@
|
|||||||
# PROGRAMMER # Programmer id (enables programmer support)
|
# PROGRAMMER # Programmer id (enables programmer support)
|
||||||
# AFLAGS # Avrdude flags for target
|
# AFLAGS # Avrdude flags for target
|
||||||
# NO_AUTOLIBS # Disables Arduino library detection
|
# NO_AUTOLIBS # Disables Arduino library detection
|
||||||
|
# MANUAL # (Advanced) Only use AVR Libc/Includes
|
||||||
#
|
#
|
||||||
# Here is a short example for a target named test:
|
# Here is a short example for a target named test:
|
||||||
#
|
#
|
||||||
@ -86,14 +88,25 @@
|
|||||||
# All variables need to be prefixed with the target name (${TARGET_NAME}_${OPTION}).
|
# All variables need to be prefixed with the target name (${TARGET_NAME}_${OPTION}).
|
||||||
#
|
#
|
||||||
#=============================================================================#
|
#=============================================================================#
|
||||||
# generate_arduino_example(LIBRARY_NAME EXAMPLE_NAME BOARD_ID [PORT] [SERIAL])
|
# generate_arduino_example(name
|
||||||
|
# LIBRARY library_name
|
||||||
|
# EXAMPLE example_name
|
||||||
|
# [BOARD board_id]
|
||||||
|
# [PORT port]
|
||||||
|
# [SERIAL serial command]
|
||||||
|
# [PORGRAMMER programmer_id]
|
||||||
|
# [AFLAGS avrdude_flags])
|
||||||
#=============================================================================#
|
#=============================================================================#
|
||||||
#
|
#
|
||||||
# BOARD_ID - Board ID
|
# name - The name of the library example [REQUIRED]
|
||||||
# LIBRARY_NAME - Library name
|
# LIBRARY - Library name [REQUIRED]
|
||||||
# EXAMPLE_NAME - Example name
|
# EXAMPLE - Example name [REQUIRED]
|
||||||
|
# BOARD - Board ID
|
||||||
# PORT - Serial port [optional]
|
# PORT - Serial port [optional]
|
||||||
# SERIAL - Serial command [optional]
|
# SERIAL - Serial command [optional]
|
||||||
|
# PROGRAMMER - Programmer id (enables programmer support)
|
||||||
|
# AFLAGS - Avrdude flags for target
|
||||||
|
#
|
||||||
# Creates a example from the specified library.
|
# Creates a example from the specified library.
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
@ -225,7 +238,7 @@ endfunction()
|
|||||||
function(GENERATE_ARDUINO_LIBRARY INPUT_NAME)
|
function(GENERATE_ARDUINO_LIBRARY INPUT_NAME)
|
||||||
message(STATUS "Generating ${INPUT_NAME}")
|
message(STATUS "Generating ${INPUT_NAME}")
|
||||||
parse_generator_arguments(${INPUT_NAME} INPUT
|
parse_generator_arguments(${INPUT_NAME} INPUT
|
||||||
"NO_AUTOLIBS" # Options
|
"NO_AUTOLIBS;MANUAL" # Options
|
||||||
"BOARD" # One Value Keywords
|
"BOARD" # One Value Keywords
|
||||||
"SRCS;HDRS;LIBS" # Multi Value Keywords
|
"SRCS;HDRS;LIBS" # Multi Value Keywords
|
||||||
${ARGN})
|
${ARGN})
|
||||||
@ -233,17 +246,22 @@ function(GENERATE_ARDUINO_LIBRARY INPUT_NAME)
|
|||||||
if(NOT INPUT_BOARD)
|
if(NOT INPUT_BOARD)
|
||||||
set(INPUT_BOARD ${ARDUINO_DEFAULT_BOARD})
|
set(INPUT_BOARD ${ARDUINO_DEFAULT_BOARD})
|
||||||
endif()
|
endif()
|
||||||
|
if(NOT INPUT_MANUAL)
|
||||||
|
set(INPUT_MANUAL FALSE)
|
||||||
|
endif()
|
||||||
required_variables(VARS INPUT_SRCS INPUT_BOARD MSG "must define for target ${INPUT_NAME}")
|
required_variables(VARS INPUT_SRCS INPUT_BOARD MSG "must define for target ${INPUT_NAME}")
|
||||||
|
|
||||||
set(ALL_LIBS)
|
set(ALL_LIBS)
|
||||||
set(ALL_SRCS ${INPUT_SRCS} ${INPUT_HDRS})
|
set(ALL_SRCS ${INPUT_SRCS} ${INPUT_HDRS})
|
||||||
|
|
||||||
setup_arduino_core(CORE_LIB ${INPUT_BOARD})
|
if(NOT INPUT_MANUAL)
|
||||||
|
setup_arduino_core(CORE_LIB ${INPUT_BOARD})
|
||||||
|
endif()
|
||||||
|
|
||||||
find_arduino_libraries(TARGET_LIBS "${ALL_SRCS}")
|
find_arduino_libraries(TARGET_LIBS "${ALL_SRCS}")
|
||||||
set(LIB_DEP_INCLUDES)
|
set(LIB_DEP_INCLUDES)
|
||||||
foreach(LIB_DEP ${TARGET_LIBS})
|
foreach(LIB_DEP ${TARGET_LIBS})
|
||||||
set(LIB_DEP_INCLUDES "${LIB_DEP_INCLUDES} -I${LIB_DEP}")
|
set(LIB_DEP_INCLUDES "${LIB_DEP_INCLUDES} -I\"${LIB_DEP}\"")
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
if(NOT ${INPUT_NO_AUTOLIBS})
|
if(NOT ${INPUT_NO_AUTOLIBS})
|
||||||
@ -254,7 +272,7 @@ function(GENERATE_ARDUINO_LIBRARY INPUT_NAME)
|
|||||||
|
|
||||||
add_library(${INPUT_NAME} ${ALL_SRCS})
|
add_library(${INPUT_NAME} ${ALL_SRCS})
|
||||||
|
|
||||||
get_arduino_flags(ARDUINO_COMPILE_FLAGS ARDUINO_LINK_FLAGS ${INPUT_BOARD})
|
get_arduino_flags(ARDUINO_COMPILE_FLAGS ARDUINO_LINK_FLAGS ${INPUT_BOARD} ${INPUT_MANUAL})
|
||||||
|
|
||||||
set_target_properties(${INPUT_NAME} PROPERTIES
|
set_target_properties(${INPUT_NAME} PROPERTIES
|
||||||
COMPILE_FLAGS "${ARDUINO_COMPILE_FLAGS} ${COMPILE_FLAGS} ${LIB_DEP_INCLUDES}"
|
COMPILE_FLAGS "${ARDUINO_COMPILE_FLAGS} ${COMPILE_FLAGS} ${LIB_DEP_INCLUDES}"
|
||||||
@ -270,9 +288,9 @@ endfunction()
|
|||||||
function(GENERATE_ARDUINO_FIRMWARE INPUT_NAME)
|
function(GENERATE_ARDUINO_FIRMWARE INPUT_NAME)
|
||||||
message(STATUS "Generating ${INPUT_NAME}")
|
message(STATUS "Generating ${INPUT_NAME}")
|
||||||
parse_generator_arguments(${INPUT_NAME} INPUT
|
parse_generator_arguments(${INPUT_NAME} INPUT
|
||||||
"NO_AUTOLIBS" # Options
|
"NO_AUTOLIBS;MANUAL" # Options
|
||||||
"BOARD;PORT;SKETCH;SERIAL;PROGRAMMER" # One Value Keywords
|
"BOARD;PORT;SKETCH;PROGRAMMER" # One Value Keywords
|
||||||
"SRCS;HDRS;LIBS;AFLAGS" # Multi Value Keywords
|
"SERIAL;SRCS;HDRS;LIBS;AFLAGS" # Multi Value Keywords
|
||||||
${ARGN})
|
${ARGN})
|
||||||
|
|
||||||
if(NOT INPUT_BOARD)
|
if(NOT INPUT_BOARD)
|
||||||
@ -285,7 +303,10 @@ function(GENERATE_ARDUINO_FIRMWARE INPUT_NAME)
|
|||||||
set(INPUT_SERIAL ${ARDUINO_DEFAULT_SERIAL})
|
set(INPUT_SERIAL ${ARDUINO_DEFAULT_SERIAL})
|
||||||
endif()
|
endif()
|
||||||
if(NOT INPUT_PROGRAMMER)
|
if(NOT INPUT_PROGRAMMER)
|
||||||
set(INPUT_SERIAL ${ARDUINO_DEFAULT_PROGRAMMER})
|
set(INPUT_PROGRAMMER ${ARDUINO_DEFAULT_PROGRAMMER})
|
||||||
|
endif()
|
||||||
|
if(NOT INPUT_MANUAL)
|
||||||
|
set(INPUT_MANUAL FALSE)
|
||||||
endif()
|
endif()
|
||||||
required_variables(VARS INPUT_BOARD MSG "must define for target ${INPUT_NAME}")
|
required_variables(VARS INPUT_BOARD MSG "must define for target ${INPUT_NAME}")
|
||||||
|
|
||||||
@ -293,19 +314,21 @@ function(GENERATE_ARDUINO_FIRMWARE INPUT_NAME)
|
|||||||
set(ALL_SRCS ${INPUT_SRCS} ${INPUT_HDRS})
|
set(ALL_SRCS ${INPUT_SRCS} ${INPUT_HDRS})
|
||||||
set(LIB_DEP_INCLUDES)
|
set(LIB_DEP_INCLUDES)
|
||||||
|
|
||||||
setup_arduino_core(CORE_LIB ${INPUT_BOARD})
|
if(NOT INPUT_MANUAL)
|
||||||
|
setup_arduino_core(CORE_LIB ${INPUT_BOARD})
|
||||||
|
endif()
|
||||||
|
|
||||||
if(NOT "${INPUT_SKETCH}" STREQUAL "")
|
if(NOT "${INPUT_SKETCH}" STREQUAL "")
|
||||||
get_filename_component(INPUT_SKETCH "${INPUT_SKETCH}" ABSOLUTE)
|
get_filename_component(INPUT_SKETCH "${INPUT_SKETCH}" ABSOLUTE)
|
||||||
setup_arduino_sketch(${INPUT_NAME} ${INPUT_SKETCH} ALL_SRCS)
|
setup_arduino_sketch(${INPUT_NAME} ${INPUT_SKETCH} ALL_SRCS)
|
||||||
set(LIB_DEP_INCLUDES "${LIB_DEP_INCLUDES} -I${INPUT_SKETCH}")
|
set(LIB_DEP_INCLUDES "${LIB_DEP_INCLUDES} -I\"${INPUT_SKETCH}\"")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
required_variables(VARS ALL_SRCS MSG "must define SRCS or SKETCH for target ${INPUT_NAME}")
|
required_variables(VARS ALL_SRCS MSG "must define SRCS or SKETCH for target ${INPUT_NAME}")
|
||||||
|
|
||||||
find_arduino_libraries(TARGET_LIBS "${ALL_SRCS}")
|
find_arduino_libraries(TARGET_LIBS "${ALL_SRCS}")
|
||||||
foreach(LIB_DEP ${TARGET_LIBS})
|
foreach(LIB_DEP ${TARGET_LIBS})
|
||||||
set(LIB_DEP_INCLUDES "${LIB_DEP_INCLUDES} -I${LIB_DEP}")
|
set(LIB_DEP_INCLUDES "${LIB_DEP_INCLUDES} -I\"${LIB_DEP}\"")
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
if(NOT INPUT_NO_AUTOLIBS)
|
if(NOT INPUT_NO_AUTOLIBS)
|
||||||
@ -314,39 +337,29 @@ function(GENERATE_ARDUINO_FIRMWARE INPUT_NAME)
|
|||||||
|
|
||||||
list(APPEND ALL_LIBS ${CORE_LIB} ${INPUT_LIBS})
|
list(APPEND ALL_LIBS ${CORE_LIB} ${INPUT_LIBS})
|
||||||
|
|
||||||
setup_arduino_target(${INPUT_NAME} ${INPUT_BOARD} "${ALL_SRCS}" "${ALL_LIBS}" "${LIB_DEP_INCLUDES}" "")
|
setup_arduino_target(${INPUT_NAME} ${INPUT_BOARD} "${ALL_SRCS}" "${ALL_LIBS}" "${LIB_DEP_INCLUDES}" "" "${INPUT_MANUAL}")
|
||||||
|
|
||||||
if(INPUT_PORT)
|
if(INPUT_PORT)
|
||||||
setup_arduino_upload(${INPUT_BOARD} ${INPUT_NAME} ${INPUT_PORT} "${INPUT_PROGRAMMER}" "${INPUT_AFLAGS}")
|
setup_arduino_upload(${INPUT_BOARD} ${INPUT_NAME} ${INPUT_PORT} "${INPUT_PROGRAMMER}" "${INPUT_AFLAGS}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(INPUT_SERIAL)
|
if(INPUT_SERIAL)
|
||||||
setup_serial_target(${INPUT_NAME} "${INPUT_SERIAL}")
|
setup_serial_target(${INPUT_NAME} "${INPUT_SERIAL}" "${INPUT_PORT}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
#=============================================================================#
|
#=============================================================================#
|
||||||
# [PUBLIC/USER]
|
# [PUBLIC/USER]
|
||||||
#
|
|
||||||
# generate_arduino_example(LIBRARY_NAME EXAMPLE_NAME BOARD_ID [PORT] [SERIAL] [PORGRAMMER])
|
|
||||||
#
|
|
||||||
# see documentation at top
|
# see documentation at top
|
||||||
#=============================================================================#
|
#=============================================================================#
|
||||||
function(GENERATE_ARDUINO_EXAMPLE LIBRARY_NAME EXAMPLE_NAME)
|
function(GENERATE_ARDUINO_EXAMPLE INPUT_NAME)
|
||||||
#TODO: Add support for options like generate_arduino_*
|
|
||||||
|
|
||||||
set(TARGET_NAME "example-${LIBRARY_NAME}-${EXAMPLE_NAME}")
|
|
||||||
|
|
||||||
message(STATUS "Generating example ${LIBRARY_NAME}-${EXAMPLE_NAME}")
|
message(STATUS "Generating example ${LIBRARY_NAME}-${EXAMPLE_NAME}")
|
||||||
|
parse_generator_arguments(${INPUT_NAME} INPUT
|
||||||
set(ALL_LIBS)
|
"" # Options
|
||||||
set(ALL_SRCS)
|
"LIBRARY;EXAMPLE;BOARD;PORT;PROGRAMMER" # One Value Keywords
|
||||||
|
"SERIAL;AFLAGS" # Multi Value Keywords
|
||||||
set(INPUT_BOARD ${ARGV2})
|
${ARGN})
|
||||||
set(INPUT_PORT ${ARGV3})
|
|
||||||
set(INPUT_SERIAL ${ARGV4})
|
|
||||||
set(INPUT_PROGRAMMER ${ARGV5})
|
|
||||||
|
|
||||||
if(NOT INPUT_BOARD)
|
if(NOT INPUT_BOARD)
|
||||||
set(INPUT_BOARD ${ARDUINO_DEFAULT_BOARD})
|
set(INPUT_BOARD ${ARDUINO_DEFAULT_BOARD})
|
||||||
@ -358,12 +371,17 @@ function(GENERATE_ARDUINO_EXAMPLE LIBRARY_NAME EXAMPLE_NAME)
|
|||||||
set(INPUT_SERIAL ${ARDUINO_DEFAULT_SERIAL})
|
set(INPUT_SERIAL ${ARDUINO_DEFAULT_SERIAL})
|
||||||
endif()
|
endif()
|
||||||
if(NOT INPUT_PROGRAMMER)
|
if(NOT INPUT_PROGRAMMER)
|
||||||
set(INPUT_SERIAL ${ARDUINO_DEFAULT_PROGRAMMER})
|
set(INPUT_PROGRAMMER ${ARDUINO_DEFAULT_PROGRAMMER})
|
||||||
endif()
|
endif()
|
||||||
|
required_variables(VARS INPUT_LIBRARY INPUT_EXAMPLE INPUT_BOARD
|
||||||
|
MSG "must define for target ${INPUT_NAME}")
|
||||||
|
|
||||||
|
set(ALL_LIBS)
|
||||||
|
set(ALL_SRCS)
|
||||||
|
|
||||||
setup_arduino_core(CORE_LIB ${INPUT_BOARD})
|
setup_arduino_core(CORE_LIB ${INPUT_BOARD})
|
||||||
|
|
||||||
setup_arduino_example("${TARGET_NAME}" "${LIBRARY_NAME}" "${EXAMPLE_NAME}" ALL_SRCS)
|
setup_arduino_example("${INPUT_NAME}" "${INPUT_LIBRARY}" "${INPUT_EXAMPLE}" ALL_SRCS)
|
||||||
|
|
||||||
if(NOT ALL_SRCS)
|
if(NOT ALL_SRCS)
|
||||||
message(FATAL_ERROR "Missing sources for example, aborting!")
|
message(FATAL_ERROR "Missing sources for example, aborting!")
|
||||||
@ -372,22 +390,21 @@ function(GENERATE_ARDUINO_EXAMPLE LIBRARY_NAME EXAMPLE_NAME)
|
|||||||
find_arduino_libraries(TARGET_LIBS "${ALL_SRCS}")
|
find_arduino_libraries(TARGET_LIBS "${ALL_SRCS}")
|
||||||
set(LIB_DEP_INCLUDES)
|
set(LIB_DEP_INCLUDES)
|
||||||
foreach(LIB_DEP ${TARGET_LIBS})
|
foreach(LIB_DEP ${TARGET_LIBS})
|
||||||
set(LIB_DEP_INCLUDES "${LIB_DEP_INCLUDES} -I${LIB_DEP}")
|
set(LIB_DEP_INCLUDES "${LIB_DEP_INCLUDES} -I\"${LIB_DEP}\"")
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
setup_arduino_libraries(ALL_LIBS ${INPUT_BOARD} "${ALL_SRCS}" "${LIB_DEP_INCLUDES}" "")
|
setup_arduino_libraries(ALL_LIBS ${INPUT_BOARD} "${ALL_SRCS}" "${LIB_DEP_INCLUDES}" "")
|
||||||
|
|
||||||
list(APPEND ALL_LIBS ${CORE_LIB} ${INPUT_LIBS})
|
list(APPEND ALL_LIBS ${CORE_LIB} ${INPUT_LIBS})
|
||||||
|
|
||||||
setup_arduino_target(${TARGET_NAME} ${INPUT_BOARD} "${ALL_SRCS}" "${ALL_LIBS}" "${LIB_DEP_INCLUDES}" "")
|
setup_arduino_target(${INPUT_NAME} ${INPUT_BOARD} "${ALL_SRCS}" "${ALL_LIBS}" "${LIB_DEP_INCLUDES}" "" FALSE)
|
||||||
|
|
||||||
if(INPUT_PORT)
|
if(INPUT_PORT)
|
||||||
#TODO fill in options (AFLAGS)
|
setup_arduino_upload(${INPUT_BOARD} ${INPUT_NAME} ${INPUT_PORT} "${INPUT_PROGRAMMER}" "${INPUT_AFLAGS}")
|
||||||
setup_arduino_upload(${INPUT_BOARD} ${TARGET_NAME} ${INPUT_PORT} "${INPUT_PROGRAMMER}" "")
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(INPUT_SERIAL)
|
if(INPUT_SERIAL)
|
||||||
setup_serial_target(${TARGET_NAME} "${INPUT_SERIAL}")
|
setup_serial_target(${INPUT_NAME} "${INPUT_SERIAL}" "${INPUT_PORT}")
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
@ -470,16 +487,18 @@ endfunction()
|
|||||||
#=============================================================================#
|
#=============================================================================#
|
||||||
# [PRIVATE/INTERNAL]
|
# [PRIVATE/INTERNAL]
|
||||||
#
|
#
|
||||||
# get_arduino_flags(COMPILE_FLAGS LINK_FLAGS BOARD_ID)
|
# get_arduino_flags(COMPILE_FLAGS LINK_FLAGS BOARD_ID MANUAL)
|
||||||
#
|
#
|
||||||
# COMPILE_FLAGS_VAR -Variable holding compiler flags
|
# COMPILE_FLAGS_VAR -Variable holding compiler flags
|
||||||
# LINK_FLAGS_VAR - Variable holding linker flags
|
# LINK_FLAGS_VAR - Variable holding linker flags
|
||||||
# BOARD_ID - The board id name
|
# BOARD_ID - The board id name
|
||||||
|
# MANUAL - (Advanced) Only use AVR Libc/Includes
|
||||||
#
|
#
|
||||||
# Configures the the build settings for the specified Arduino Board.
|
# Configures the the build settings for the specified Arduino Board.
|
||||||
#
|
#
|
||||||
#=============================================================================#
|
#=============================================================================#
|
||||||
function(get_arduino_flags COMPILE_FLAGS_VAR LINK_FLAGS_VAR BOARD_ID)
|
function(get_arduino_flags COMPILE_FLAGS_VAR LINK_FLAGS_VAR BOARD_ID MANUAL)
|
||||||
|
|
||||||
set(BOARD_CORE ${${BOARD_ID}.build.core})
|
set(BOARD_CORE ${${BOARD_ID}.build.core})
|
||||||
if(BOARD_CORE)
|
if(BOARD_CORE)
|
||||||
if(ARDUINO_SDK_VERSION MATCHES "([0-9]+)[.]([0-9]+)")
|
if(ARDUINO_SDK_VERSION MATCHES "([0-9]+)[.]([0-9]+)")
|
||||||
@ -498,11 +517,16 @@ function(get_arduino_flags COMPILE_FLAGS_VAR LINK_FLAGS_VAR BOARD_ID)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# output
|
# output
|
||||||
set(COMPILE_FLAGS "-DF_CPU=${${BOARD_ID}.build.f_cpu} -DARDUINO=${ARDUINO_VERSION_DEFINE} -mmcu=${${BOARD_ID}.build.mcu} -I${ARDUINO_CORES_PATH}/${BOARD_CORE} -I${ARDUINO_LIBRARIES_PATH}")
|
set(COMPILE_FLAGS "-DF_CPU=${${BOARD_ID}.build.f_cpu} -DARDUINO=${ARDUINO_VERSION_DEFINE} -mmcu=${${BOARD_ID}.build.mcu}")
|
||||||
|
if(NOT MANUAL)
|
||||||
|
set(COMPILE_FLAGS "${COMPILE_FLAGS} -I\"${ARDUINO_CORES_PATH}/${BOARD_CORE}\" -I\"${ARDUINO_LIBRARIES_PATH}\"")
|
||||||
|
endif()
|
||||||
set(LINK_FLAGS "-mmcu=${${BOARD_ID}.build.mcu}")
|
set(LINK_FLAGS "-mmcu=${${BOARD_ID}.build.mcu}")
|
||||||
if(ARDUINO_SDK_VERSION VERSION_GREATER 1.0 OR ARDUINO_SDK_VERSION VERSION_EQUAL 1.0)
|
if(ARDUINO_SDK_VERSION VERSION_GREATER 1.0 OR ARDUINO_SDK_VERSION VERSION_EQUAL 1.0)
|
||||||
set(PIN_HEADER ${${BOARD_ID}.build.variant})
|
set(PIN_HEADER ${${BOARD_ID}.build.variant})
|
||||||
set(COMPILE_FLAGS "${COMPILE_FLAGS} -I${ARDUINO_VARIANTS_PATH}/${PIN_HEADER}")
|
if(NOT MANUAL)
|
||||||
|
set(COMPILE_FLAGS "${COMPILE_FLAGS} -I\"${ARDUINO_VARIANTS_PATH}/${PIN_HEADER}\"")
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# output
|
# output
|
||||||
@ -536,7 +560,7 @@ function(setup_arduino_core VAR_NAME BOARD_ID)
|
|||||||
# Debian/Ubuntu fix
|
# Debian/Ubuntu fix
|
||||||
list(REMOVE_ITEM CORE_SRCS "${BOARD_CORE_PATH}/main.cxx")
|
list(REMOVE_ITEM CORE_SRCS "${BOARD_CORE_PATH}/main.cxx")
|
||||||
add_library(${CORE_LIB_NAME} ${CORE_SRCS})
|
add_library(${CORE_LIB_NAME} ${CORE_SRCS})
|
||||||
get_arduino_flags(ARDUINO_COMPILE_FLAGS ARDUINO_LINK_FLAGS ${BOARD_ID})
|
get_arduino_flags(ARDUINO_COMPILE_FLAGS ARDUINO_LINK_FLAGS ${BOARD_ID} FALSE)
|
||||||
set_target_properties(${CORE_LIB_NAME} PROPERTIES
|
set_target_properties(${CORE_LIB_NAME} PROPERTIES
|
||||||
COMPILE_FLAGS "${ARDUINO_COMPILE_FLAGS}"
|
COMPILE_FLAGS "${ARDUINO_COMPILE_FLAGS}"
|
||||||
LINK_FLAGS "${ARDUINO_LINK_FLAGS}")
|
LINK_FLAGS "${ARDUINO_LINK_FLAGS}")
|
||||||
@ -641,7 +665,7 @@ function(setup_arduino_library VAR_NAME BOARD_ID LIB_PATH COMPILE_FLAGS LINK_FLA
|
|||||||
arduino_debug_msg("Generating Arduino ${LIB_NAME} library")
|
arduino_debug_msg("Generating Arduino ${LIB_NAME} library")
|
||||||
add_library(${TARGET_LIB_NAME} STATIC ${LIB_SRCS})
|
add_library(${TARGET_LIB_NAME} STATIC ${LIB_SRCS})
|
||||||
|
|
||||||
get_arduino_flags(ARDUINO_COMPILE_FLAGS ARDUINO_LINK_FLAGS ${BOARD_ID})
|
get_arduino_flags(ARDUINO_COMPILE_FLAGS ARDUINO_LINK_FLAGS ${BOARD_ID} FALSE)
|
||||||
|
|
||||||
find_arduino_libraries(LIB_DEPS "${LIB_SRCS}")
|
find_arduino_libraries(LIB_DEPS "${LIB_SRCS}")
|
||||||
|
|
||||||
@ -651,7 +675,7 @@ function(setup_arduino_library VAR_NAME BOARD_ID LIB_PATH COMPILE_FLAGS LINK_FLA
|
|||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
set_target_properties(${TARGET_LIB_NAME} PROPERTIES
|
set_target_properties(${TARGET_LIB_NAME} PROPERTIES
|
||||||
COMPILE_FLAGS "${ARDUINO_COMPILE_FLAGS} -I${LIB_PATH} -I${LIB_PATH}/utility ${COMPILE_FLAGS}"
|
COMPILE_FLAGS "${ARDUINO_COMPILE_FLAGS} -I\"${LIB_PATH}\" -I\"${LIB_PATH}/utility\" ${COMPILE_FLAGS}"
|
||||||
LINK_FLAGS "${ARDUINO_LINK_FLAGS} ${LINK_FLAGS}")
|
LINK_FLAGS "${ARDUINO_LINK_FLAGS} ${LINK_FLAGS}")
|
||||||
|
|
||||||
target_link_libraries(${TARGET_LIB_NAME} ${BOARD_ID}_CORE ${LIB_TARGETS})
|
target_link_libraries(${TARGET_LIB_NAME} ${BOARD_ID}_CORE ${LIB_TARGETS})
|
||||||
@ -697,7 +721,7 @@ endfunction()
|
|||||||
#=============================================================================#
|
#=============================================================================#
|
||||||
# [PRIVATE/INTERNAL]
|
# [PRIVATE/INTERNAL]
|
||||||
#
|
#
|
||||||
# setup_arduino_target(TARGET_NAME ALL_SRCS ALL_LIBS COMPILE_FLAGS LINK_FLAGS)
|
# setup_arduino_target(TARGET_NAME ALL_SRCS ALL_LIBS COMPILE_FLAGS LINK_FLAGS MANUAL)
|
||||||
#
|
#
|
||||||
# TARGET_NAME - Target name
|
# TARGET_NAME - Target name
|
||||||
# BOARD_ID - Arduino board ID
|
# BOARD_ID - Arduino board ID
|
||||||
@ -705,16 +729,17 @@ endfunction()
|
|||||||
# ALL_LIBS - All libraries
|
# ALL_LIBS - All libraries
|
||||||
# COMPILE_FLAGS - Compile flags
|
# COMPILE_FLAGS - Compile flags
|
||||||
# LINK_FLAGS - Linker flags
|
# LINK_FLAGS - Linker flags
|
||||||
|
# MANUAL - (Advanced) Only use AVR Libc/Includes
|
||||||
#
|
#
|
||||||
# Creates an Arduino firmware target.
|
# Creates an Arduino firmware target.
|
||||||
#
|
#
|
||||||
#=============================================================================#
|
#=============================================================================#
|
||||||
function(setup_arduino_target TARGET_NAME BOARD_ID ALL_SRCS ALL_LIBS COMPILE_FLAGS LINK_FLAGS)
|
function(setup_arduino_target TARGET_NAME BOARD_ID ALL_SRCS ALL_LIBS COMPILE_FLAGS LINK_FLAGS MANUAL)
|
||||||
|
|
||||||
add_executable(${TARGET_NAME} ${ALL_SRCS})
|
add_executable(${TARGET_NAME} ${ALL_SRCS})
|
||||||
set_target_properties(${TARGET_NAME} PROPERTIES SUFFIX ".elf")
|
set_target_properties(${TARGET_NAME} PROPERTIES SUFFIX ".elf")
|
||||||
|
|
||||||
get_arduino_flags(ARDUINO_COMPILE_FLAGS ARDUINO_LINK_FLAGS ${BOARD_ID})
|
get_arduino_flags(ARDUINO_COMPILE_FLAGS ARDUINO_LINK_FLAGS ${BOARD_ID} ${MANUAL})
|
||||||
|
|
||||||
set_target_properties(${TARGET_NAME} PROPERTIES
|
set_target_properties(${TARGET_NAME} PROPERTIES
|
||||||
COMPILE_FLAGS "${ARDUINO_COMPILE_FLAGS} ${COMPILE_FLAGS}"
|
COMPILE_FLAGS "${ARDUINO_COMPILE_FLAGS} ${COMPILE_FLAGS}"
|
||||||
@ -812,6 +837,13 @@ function(setup_arduino_bootloader_upload TARGET_NAME BOARD_ID PORT AVRDUDE_FLAGS
|
|||||||
${ARDUINO_AVRDUDE_PROGRAM}
|
${ARDUINO_AVRDUDE_PROGRAM}
|
||||||
${AVRDUDE_ARGS}
|
${AVRDUDE_ARGS}
|
||||||
DEPENDS ${TARGET_NAME})
|
DEPENDS ${TARGET_NAME})
|
||||||
|
|
||||||
|
# Global upload target
|
||||||
|
if(NOT TARGET upload)
|
||||||
|
add_custom_target(upload)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_dependencies(upload ${UPLOAD_TARGET})
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
#=============================================================================#
|
#=============================================================================#
|
||||||
@ -1058,10 +1090,10 @@ endfunction()
|
|||||||
# Creates a target (${TARGET_NAME}-serial) for launching the serial termnial.
|
# Creates a target (${TARGET_NAME}-serial) for launching the serial termnial.
|
||||||
#
|
#
|
||||||
#=============================================================================#
|
#=============================================================================#
|
||||||
function(setup_serial_target TARGET_NAME CMD)
|
function(setup_serial_target TARGET_NAME CMD SERIAL_PORT)
|
||||||
string(CONFIGURE "${CMD}" FULL_CMD @ONLY)
|
string(CONFIGURE "${CMD}" FULL_CMD @ONLY)
|
||||||
add_custom_target(${TARGET_NAME}-serial
|
add_custom_target(${TARGET_NAME}-serial
|
||||||
${FULL_CMD})
|
COMMAND ${FULL_CMD})
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
|
||||||
@ -1330,7 +1362,7 @@ function(SETUP_ARDUINO_SKETCH TARGET_NAME SKETCH_PATH OUTPUT_VAR)
|
|||||||
|
|
||||||
set("${OUTPUT_VAR}" ${${OUTPUT_VAR}} ${SKETCH_CPP} PARENT_SCOPE)
|
set("${OUTPUT_VAR}" ${${OUTPUT_VAR}} ${SKETCH_CPP} PARENT_SCOPE)
|
||||||
else()
|
else()
|
||||||
message(FATAL_ERROR "Sketch does not exist: ${SKETCH_PDE}")
|
message(FATAL_ERROR "Sketch does not exist: ${SKETCH_PATH}")
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user