diff --git a/Arduino/System/BoardBuildTargets.cmake b/Arduino/System/BoardBuildTargets.cmake index b61f19a..b2936fe 100644 --- a/Arduino/System/BoardBuildTargets.cmake +++ b/Arduino/System/BoardBuildTargets.cmake @@ -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) @@ -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)