Skip to content

Commit

Permalink
Include directories when setting up the library. Added Servo_RECURSE.
Browse files Browse the repository at this point in the history
  • Loading branch information
francoiscampbell committed Feb 17, 2016
1 parent 3c7817f commit dbd4fe3
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions cmake/Platform/Arduino.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -955,18 +955,15 @@ function(find_arduino_libraries VAR_NAME SRCS ARDLIBS)
foreach(LIB_SEARCH_PATH ${include_dirs} ${LIBRARY_SEARCH_PATH} ${ARDUINO_LIBRARIES_PATH} ${${ARDUINO_PLATFORM}_LIBRARIES_PATH} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/libraries ${ARDUINO_EXTRA_LIBRARIES_PATH})
if(EXISTS ${LIB_SEARCH_PATH}/${INCLUDE_NAME}/${CMAKE_MATCH_1})
list(APPEND ARDUINO_LIBS ${LIB_SEARCH_PATH}/${INCLUDE_NAME})
include_directories(${LIB_SEARCH_PATH}/${INCLUDE_NAME})
break()
endif()
if(EXISTS ${LIB_SEARCH_PATH}/${INCLUDE_NAME}/src/${CMAKE_MATCH_1})
list(APPEND ARDUINO_LIBS ${LIB_SEARCH_PATH}/${INCLUDE_NAME})
include_directories(${LIB_SEARCH_PATH}/${INCLUDE_NAME}/src)
break()
endif()
get_source_file_property(_header_generated ${LIB_SEARCH_PATH}/${CMAKE_MATCH_1} GENERATED)
if((EXISTS ${LIB_SEARCH_PATH}/${CMAKE_MATCH_1}) OR ${_header_generated})
list(APPEND ARDUINO_LIBS ${LIB_SEARCH_PATH})
include_directories(${LIB_SEARCH_PATH})
list(APPEND ARDUINO_LIBS ${LIB_SEARCH_PATH}/${INCLUDE_NAME})

This comment has been minimized.

Copy link
@ryanpfeeley

ryanpfeeley Apr 23, 2016

I'm not sure the inclusion of the /${INCLUDE_NAME} is the right call. For me this created errors in a situation where I had an Arduino library that didn't contain any header files matching the library name (bad style I know). Previously I was able to use link_directories(${CMAKE_CURRENT_LIST_DIR}/libraries/myWeirdLibrary) and it was included properly.

This may cause other errors as well. Perhaps this is a cut-and-paste bug? The conditional checks for
EXISTS ${LIB_SEARCH_PATH}/${CMAKE_MATCH_1}
but then adds the (possibly nonexistent directory)
${LIB_SEARCH_PATH}/${INCLUDE_NAME}
Which is the pattern above, but I don't think that is right here.

FYI, there is a parsing error on the regex above. It won't find any #includes that have trailing whitespace or comments. I'll make a pull request for that at some point.

break()
endif()
endforeach()
Expand Down Expand Up @@ -1002,6 +999,7 @@ endfunction()
set(Wire_RECURSE True)
set(Ethernet_RECURSE True)
set(SD_RECURSE True)
set(Servo_RECURSE True)
set(SPI_RECURSE True)
set(SoftwareSerial_RECURSE True)
set(EEPROM_RECURSE True)
Expand All @@ -1028,6 +1026,9 @@ function(setup_arduino_library VAR_NAME BOARD_ID LIB_PATH COMPILE_FLAGS LINK_FLA
message(STATUS "Generating ${TARGET_LIB_NAME} for library ${LIB_NAME}")
arduino_debug_msg("Generating Arduino ${LIB_NAME} library")
add_library(${TARGET_LIB_NAME} STATIC ${LIB_SRCS})
include_directories(${LIB_PATH})
include_directories(${LIB_PATH}/src)
include_directories(${LIB_PATH}/utility)

get_arduino_flags(ARDUINO_COMPILE_FLAGS ARDUINO_LINK_FLAGS ${BOARD_ID} FALSE)

Expand Down

0 comments on commit dbd4fe3

Please sign in to comment.