Skip to content

Commit a98d20d

Browse files
Fixed error handling bug in arduino library linking (#32)
Previously, _lib_name could still carry the value from previous find_arduino_library invocations. When trying to link with nonexistent libraries, this could "mask" the error in library searching and lead to an erroneously successfully completing cmake run.
1 parent e4252c5 commit a98d20d

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

Arduino/System/BoardBuildTargets.cmake

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,7 @@ function(find_arduino_library lib return_lib_path)
464464

465465
# message("Search namespaces: ${ard_libs_ns_list}")
466466

467+
set(_lib_name)
467468
if (DEFINED ARDUINO_LIB_${lib}_LIBNAME)
468469
set(_lib_name "${ARDUINO_LIB_${lib}_LIBNAME}")
469470
elseif(DEFINED ARDUINO_LIB_${lib}_PATH)
@@ -487,13 +488,15 @@ function(find_arduino_library lib return_lib_path)
487488
endif()
488489

489490
# Error message if not found
490-
if (NOT ARDUINO_LIB_${_lib_name}_PATH)
491-
if (NOT parsed_args_QUIET)
492-
message(SEND_ERROR "Arduino library ${lib} could not be found in "
493-
"${search_paths}")
491+
if (NOT _lib_name)
492+
if (NOT ARDUINO_LIB_${_lib_name}_PATH)
493+
if (NOT parsed_args_QUIET)
494+
message(SEND_ERROR "Arduino library ${lib} could not be found in "
495+
"${search_paths}")
496+
endif()
497+
set("${return_lib_path}" "${lib}-NOTFOUND" PARENT_SCOPE)
498+
return()
494499
endif()
495-
set("${return_lib_path}" "${lib}-NOTFOUND" PARENT_SCOPE)
496-
return()
497500
endif()
498501

499502
# message("find_arduino_library(\"${lib}\":${ARDUINO_LIB_${lib}_PATH})")

0 commit comments

Comments
 (0)