Skip to content
Open
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
21 changes: 14 additions & 7 deletions Arduino/System/BoardBuildTargets.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -861,8 +861,8 @@ function(_library_search_process lib search_paths_var search_suffixes_var return
# message("Folder match ${lib}:${dir}:${folder_name_priority}")

# Check for architecture match
file(STRINGS "${dir}/library.properties" arch_str REGEX "architectures=.*")
string(REGEX MATCH "architectures=(.*)" arch_list "${arch_str}")
file(STRINGS "${dir}/library.properties" arch_str REGEX "^architectures=.*")
string(REGEX MATCH "^architectures=(.*)" arch_list "${arch_str}")
string(REPLACE "," ";" arch_list "${CMAKE_MATCH_1}")
string(TOUPPER "${ARDUINO_BOARD_BUILD_ARCH}" board_arch)

Expand Down Expand Up @@ -916,11 +916,18 @@ function(_library_search_process lib search_paths_var search_suffixes_var return
endif()

# Although we got the match, let us search for the required header within the folder
file(GLOB_RECURSE lib_header_path "${matched_lib_path}/${lib}.h*")
if (NOT lib_header_path)
set ("${return_var}" "${lib}-NOTFOUND" PARENT_SCOPE)
return()
endif()
file(STRINGS "${matched_lib_path}/library.properties" incl_list REGEX "^includes=.*")
string(REGEX MATCH "^includes=(.*)" incl_list "${arch_str}")
string(REPLACE "," ";" incl_list "${CMAKE_MATCH_1}")

foreach(h ${incl_list})
file(GLOB_RECURSE lib_header_path "${matched_lib_path}/${h}.h*")
if (NOT lib_header_path)
message(STATUS "Header ${h} for ${lib} is not found.")
set ("${return_var}" "${lib}-NOTFOUND" PARENT_SCOPE)
return()
endif()
endforeach()

set ("${return_var}" "${matched_lib_path}" PARENT_SCOPE)

Expand Down