forked from queezythegreat/arduino-cmake
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add other paramether to `setup_arduino_libraries` for includes: `INCLUDE_PATHS` - Add other paramether to `setup_arduino_library` for includes: `INCLUDE_PATHS` - Removed manual `-I` as manual `COMPILE_FLAGS` with `set_target_properties` in setup_arduino_library` - Add the more CMake semantic `target_include_directories` in `setup_arduino_library`
- Loading branch information
1 parent
d221a7a
commit c20c2ae
Showing
1 changed file
with
24 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -384,11 +384,11 @@ function(GENERATE_ARDUINO_LIBRARY INPUT_NAME) | |
find_arduino_libraries(TARGET_LIBS "${ALL_SRCS}" "") | ||
set(LIB_DEP_INCLUDES) | ||
foreach(LIB_DEP ${TARGET_LIBS}) | ||
set(LIB_DEP_INCLUDES "${LIB_DEP_INCLUDES} -I\"${LIB_DEP}\"") | ||
set(LIB_DEP_INCLUDES "${LIB_DEP_INCLUDES} ${LIB_DEP}") | ||
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}" "" "" "" "${LIB_DEP_INCLUDES}") | ||
endif() | ||
|
||
list(APPEND ALL_LIBS ${CORE_LIB} ${INPUT_LIBS}) | ||
|
@@ -480,10 +480,10 @@ function(GENERATE_ARDUINO_FIRMWARE INPUT_NAME) | |
get_filename_component(INPUT_SKETCH "${INPUT_SKETCH}" ABSOLUTE) | ||
setup_arduino_sketch(${INPUT_NAME} ${INPUT_SKETCH} ALL_SRCS) | ||
if (IS_DIRECTORY "${INPUT_SKETCH}") | ||
set(LIB_DEP_INCLUDES "${LIB_DEP_INCLUDES} -I\"${INPUT_SKETCH}\"") | ||
set(LIB_DEP_INCLUDES "${LIB_DEP_INCLUDES} ${INPUT_SKETCH}") | ||
else() | ||
get_filename_component(INPUT_SKETCH_PATH "${INPUT_SKETCH}" PATH) | ||
set(LIB_DEP_INCLUDES "${LIB_DEP_INCLUDES} -I\"${INPUT_SKETCH_PATH}\"") | ||
set(LIB_DEP_INCLUDES "${LIB_DEP_INCLUDES} ${INPUT_SKETCH_PATH}") | ||
endif() | ||
endif() | ||
|
||
|
@@ -492,11 +492,11 @@ function(GENERATE_ARDUINO_FIRMWARE INPUT_NAME) | |
find_arduino_libraries(TARGET_LIBS "${ALL_SRCS}" "${INPUT_ARDLIBS}") | ||
foreach(LIB_DEP ${TARGET_LIBS}) | ||
arduino_debug_msg("Arduino Library: ${LIB_DEP}") | ||
set(LIB_DEP_INCLUDES "${LIB_DEP_INCLUDES} -I\"${LIB_DEP}\"") | ||
set(LIB_DEP_INCLUDES "${LIB_DEP_INCLUDES} ${LIB_DEP}") | ||
endforeach() | ||
|
||
if(NOT INPUT_NO_AUTOLIBS) | ||
setup_arduino_libraries(ALL_LIBS ${INPUT_BOARD} "${ALL_SRCS}" "${INPUT_ARDLIBS}" "${LIB_DEP_INCLUDES}" "") | ||
setup_arduino_libraries(ALL_LIBS ${INPUT_BOARD} "${ALL_SRCS}" "${INPUT_ARDLIBS}" "" "" "${LIB_DEP_INCLUDES}") | ||
foreach(LIB_INCLUDES ${ALL_LIBS_INCLUDES}) | ||
arduino_debug_msg("Arduino Library Includes: ${LIB_INCLUDES}") | ||
set(LIB_DEP_INCLUDES "${LIB_DEP_INCLUDES} ${LIB_INCLUDES}") | ||
|
@@ -612,10 +612,10 @@ function(GENERATE_ARDUINO_EXAMPLE INPUT_NAME) | |
find_arduino_libraries(TARGET_LIBS "${ALL_SRCS}" "") | ||
set(LIB_DEP_INCLUDES) | ||
foreach(LIB_DEP ${TARGET_LIBS}) | ||
set(LIB_DEP_INCLUDES "${LIB_DEP_INCLUDES} -I\"${LIB_DEP}\"") | ||
set(LIB_DEP_INCLUDES "${LIB_DEP_INCLUDES} ${LIB_DEP}") | ||
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}) | ||
|
||
|
@@ -931,13 +931,14 @@ endfunction() | |
#=============================================================================# | ||
# [PRIVATE/INTERNAL] | ||
# | ||
# setup_arduino_library(VAR_NAME BOARD_ID LIB_PATH COMPILE_FLAGS LINK_FLAGS) | ||
# setup_arduino_library(VAR_NAME BOARD_ID LIB_PATH COMPILE_FLAGS LINK_FLAGS INCLUDE_PATHS) | ||
# | ||
# VAR_NAME - Vairable wich will hold the generated library names | ||
# BOARD_ID - Board ID | ||
# LIB_PATH - Path of the library | ||
# COMPILE_FLAGS - Compile flags | ||
# LINK_FLAGS - Link flags | ||
# INCLUDE_PATHS - Include paths | ||
# | ||
# Creates an Arduino library, with all it's library dependencies. | ||
# | ||
|
@@ -950,7 +951,7 @@ endfunction() | |
set(Wire_RECURSE True) | ||
set(Ethernet_RECURSE True) | ||
set(SD_RECURSE True) | ||
function(setup_arduino_library VAR_NAME BOARD_ID LIB_PATH COMPILE_FLAGS LINK_FLAGS) | ||
function(setup_arduino_library VAR_NAME BOARD_ID LIB_PATH COMPILE_FLAGS LINK_FLAGS INCLUDE_PATHS) | ||
set(LIB_TARGETS) | ||
set(LIB_INCLUDES) | ||
|
||
|
@@ -975,14 +976,21 @@ function(setup_arduino_library VAR_NAME BOARD_ID LIB_PATH COMPILE_FLAGS LINK_FLA | |
find_arduino_libraries(LIB_DEPS "${LIB_SRCS}" "") | ||
|
||
foreach(LIB_DEP ${LIB_DEPS}) | ||
setup_arduino_library(DEP_LIB_SRCS ${BOARD_ID} ${LIB_DEP} "${COMPILE_FLAGS}" "${LINK_FLAGS}") | ||
setup_arduino_library(DEP_LIB_SRCS ${BOARD_ID} ${LIB_DEP} "${COMPILE_FLAGS}" "${LINK_FLAGS} ${INCLUDE_PATHS}") | ||
list(APPEND LIB_TARGETS ${DEP_LIB_SRCS}) | ||
list(APPEND LIB_INCLUDES ${DEP_LIB_SRCS_INCLUDES}) | ||
endforeach() | ||
|
||
set_target_properties(${TARGET_LIB_NAME} PROPERTIES | ||
COMPILE_FLAGS "${ARDUINO_COMPILE_FLAGS} ${LIB_INCLUDES} -I\"${LIB_PATH}\" -I\"${LIB_PATH}/utility\" ${COMPILE_FLAGS}" | ||
COMPILE_FLAGS "${ARDUINO_COMPILE_FLAGS} ${COMPILE_FLAGS}" | ||
LINK_FLAGS "${ARDUINO_LINK_FLAGS} ${LINK_FLAGS}") | ||
target_include_directories(${TARGET_NAME} | ||
PUBLIC ${LIB_PATH} | ||
PUBLIC ${LIB_PATH}/utility) | ||
foreach(DEP_LIB_SRCS_INCLUDE ${DEP_LIB_SRCS_INCLUDES}) | ||
target_include_directories(${TARGET_NAME} PUBLIC ${DEP_LIB_SRCS_INCLUDE}) | ||
endforeach(DEP_LIB_SRCS_INCLUDE ${DEP_LIB_SRCS_INCLUDES}) | ||
# TODO([email protected]): rmeove LIB_INCLUDES in file scope andchields | ||
list(APPEND LIB_INCLUDES "-I\"${LIB_PATH}\" -I\"${LIB_PATH}/utility\"") | ||
|
||
target_link_libraries(${TARGET_LIB_NAME} ${BOARD_ID}_CORE ${LIB_TARGETS}) | ||
|
@@ -1003,25 +1011,26 @@ endfunction() | |
#=============================================================================# | ||
# [PRIVATE/INTERNAL] | ||
# | ||
# setup_arduino_libraries(VAR_NAME BOARD_ID SRCS COMPILE_FLAGS LINK_FLAGS) | ||
# setup_arduino_libraries(VAR_NAME BOARD_ID SRCS COMPILE_FLAGS LINK_FLAGS INCLUDE_PATHS) | ||
# | ||
# VAR_NAME - Vairable wich will hold the generated library names | ||
# BOARD_ID - Board ID | ||
# SRCS - source files | ||
# COMPILE_FLAGS - Compile flags | ||
# LINK_FLAGS - Linker flags | ||
# INCLUDE_PATHS - Include paths | ||
# | ||
# Finds and creates all dependency libraries based on sources. | ||
# | ||
#=============================================================================# | ||
function(setup_arduino_libraries VAR_NAME BOARD_ID SRCS ARDLIBS COMPILE_FLAGS LINK_FLAGS) | ||
function(setup_arduino_libraries VAR_NAME BOARD_ID SRCS ARDLIBS COMPILE_FLAGS LINK_FLAGS INCLUDE_PATHS) | ||
set(LIB_TARGETS) | ||
set(LIB_INCLUDES) | ||
|
||
find_arduino_libraries(TARGET_LIBS "${SRCS}" ARDLIBS) | ||
foreach(TARGET_LIB ${TARGET_LIBS}) | ||
# Create static library instead of returning sources | ||
setup_arduino_library(LIB_DEPS ${BOARD_ID} ${TARGET_LIB} "${COMPILE_FLAGS}" "${LINK_FLAGS}") | ||
setup_arduino_library(LIB_DEPS ${BOARD_ID} ${TARGET_LIB} "${COMPILE_FLAGS}" "${LINK_FLAGS} ${INCLUDE_PATHS}") | ||
list(APPEND LIB_TARGETS ${LIB_DEPS}) | ||
list(APPEND LIB_INCLUDES ${LIB_DEPS_INCLUDES}) | ||
endforeach() | ||
|