Skip to content
This repository was archived by the owner on Apr 17, 2023. It is now read-only.

Commit 04e9bf2

Browse files
committed
Added optional argument to find_arduino_library function.
It instructs it to find the library without altering its' name to an "Arduino-Compliant" name.
1 parent f504bb6 commit 04e9bf2

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

cmake/Platform/Targets/ArduinoLibraryTarget.cmake

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,18 +97,22 @@ endfunction()
9797
#=============================================================================#
9898
function(find_arduino_library _target_name _library_name _board_id)
9999

100-
convert_string_to_pascal_case(${_library_name} arduino_compliant_library_name)
101-
set(library_path "${ARDUINO_SDK_LIBRARIES_PATH}/${arduino_compliant_library_name}")
100+
cmake_parse_arguments(find_lib "3RD_PARTY" "" "" ${ARGN})
101+
102+
if (NOT find_lib_3RD_PARTY)
103+
convert_string_to_pascal_case(${_library_name} _library_name)
104+
endif ()
105+
set(library_path "${ARDUINO_SDK_LIBRARIES_PATH}/${_library_name}")
102106
set(library_properties_path "${library_path}/library.properties")
103107

104108
if (NOT EXISTS "${library_properties_path}")
105-
message(SEND_ERROR "Couldn't find library named ${arduino_compliant_library_name}")
109+
message(SEND_ERROR "Couldn't find library named ${_library_name}")
106110
else () # Library is found
107111
_get_library_architecture("${library_properties_path}" lib_arch)
108112
if (lib_arch)
109113
if ("${lib_arch}" MATCHES "UNSUPPORTED")
110114
string(CONCAT error_message
111-
"${arduino_compliant_library_name} "
115+
"${_library_name} "
112116
"library isn't supported on the platform's architecture "
113117
"${ARDUINO_CMAKE_PLATFORM_ARCHITECTURE}")
114118
message(SEND_ERROR ${error_message})
@@ -126,7 +130,7 @@ function(find_arduino_library _target_name _library_name _board_id)
126130

127131
if (NOT library_sources)
128132
set(error_message
129-
"${arduino_compliant_library_name} doesn't have any source files \
133+
"${_library_name} doesn't have any source files \
130134
under the 'src' directory")
131135
message(SEND_ERROR "${error_message}")
132136
else ()

examples/custom-library/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,7 @@ add_arduino_executable(3rd_Party_Arduino_Library ${board_id} test.cpp)
77

88
add_arduino_library(Adafruit_NeoPixel_lib ${board_id} Adafruit_NeoPixel/Adafruit_NeoPixel.cpp)
99
target_include_directories(Adafruit_NeoPixel_lib PUBLIC Adafruit_NeoPixel)
10+
11+
#find_arduino_library(Adafruit_NeoPixel_lib Adafruit_NeoPixel ${board_id} 3RD_PARTY)
12+
1013
link_arduino_library(3rd_Party_Arduino_Library Adafruit_NeoPixel_lib ${board_id})

0 commit comments

Comments
 (0)