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

Commit aee9326

Browse files
committed
Added cmake's current source dir and project dir to library search paths.
It also can search the 'libraries' and 'dependencies' sub-dirs.
1 parent f2ba759 commit aee9326

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

cmake/Platform/Libraries/LibrariesFinder.cmake

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ function(find_arduino_library _target_name _library_name _board_id)
2121
find_file(library_path
2222
NAMES ${_library_name}
2323
PATHS ${ARDUINO_SDK_LIBRARIES_PATH} ${ARDUINO_CMAKE_SKETCHBOOK_PATH}
24-
PATH_SUFFIXES libraries
24+
${CMAKE_CURRENT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}
25+
PATH_SUFFIXES libraries dependencies
2526
NO_DEFAULT_PATH
2627
NO_CMAKE_FIND_ROOT_PATH)
2728

@@ -34,6 +35,7 @@ function(find_arduino_library _target_name _library_name _board_id)
3435

3536
if (NOT library_headers)
3637
message(SEND_ERROR "Couldn't find any header files for the ${_library_name} library")
38+
3739
else ()
3840

3941
if (parsed_args_HEADER_ONLY)
@@ -48,14 +50,19 @@ function(find_arduino_library _target_name _library_name _board_id)
4850
"${_library_name} library - Is it a header-only library?"
4951
"If so, please pass the HEADER_ONLY option "
5052
"as an argument to the function")
53+
5154
else ()
55+
5256
set(sources ${library_headers} ${library_sources})
5357

5458
add_arduino_library(${_target_name} ${_board_id} ${sources})
59+
5560
endif ()
5661

5762
endif ()
63+
5864
endif ()
65+
5966
endif ()
6067

6168
unset(library_path CACHE)

examples/3rd-party-library/CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ target_include_directories(3rd_Party_Arduino_Library PRIVATE include)
1212
add_arduino_library(adafruit_NeoPixel ${board_id} libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp)
1313
target_include_directories(adafruit_NeoPixel PUBLIC libraries/Adafruit_NeoPixel)
1414

15-
# Find the "GFX" library by 'tricking' the framework to use current directory as the Sketchbook path,
16-
# allowing us to use the 'find' API
17-
set(ARDUINO_CMAKE_SKETCHBOOK_PATH "${CMAKE_CURRENT_LIST_DIR}")
15+
# Find the "GFX" library - It's located under the 'libraries' sub-dir, which is a valid search path
1816
find_arduino_library(adafruit_GFX Adafruit-GFX-Library ${board_id} 3RD_PARTY)
1917
# We can also explicitly add additional directories to the target,
2018
# as only root dir and 'src' and 'utility' sub-dirs are added by default

0 commit comments

Comments
 (0)