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

Commit fbfc27e

Browse files
authored
Merge pull request #46 from arduino-cmake/feature/platform-lib-inner-dep-fix
Fixed bug where platform libraries weren't using all of their sources
2 parents aed0cb4 + 62b7fcf commit fbfc27e

File tree

14 files changed

+704
-5
lines changed

14 files changed

+704
-5
lines changed

cmake/Platform/Other/ArchitectureSupportQuery.cmake

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,14 @@ function(get_unsupported_architectures _arch_list _return_var)
4242
list(FILTER _arch_list EXCLUDE REGEX ${ARDUINO_CMAKE_PLATFORM_ARCHITECTURE})
4343
set(unsupported_arch_list ${_arch_list}) # Just for better readability
4444

45+
if (NOT unsupported_arch_list) # The only supported architecture is our platform's architecture
46+
return() # Return nothing as there are no uspported architectures
47+
endif ()
48+
4549
if (parsed_args_REGEX) # Return in regex format
4650

4751
foreach (arch ${unsupported_arch_list})
48-
# Append every unsupported-architecture and "|" to represent "or" in regex-fomart
52+
# Append an "|" to every unsupported-architecture to represent "or" in regex-fomart
4953
string(APPEND unsupported_archs_regex "${arch}" "|")
5054
endforeach ()
5155

cmake/Platform/Targets/PlatformLibraryTarget.cmake

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,19 @@ endfunction()
2929
#=============================================================================#
3030
function(_add_platform_library _library_name _board_id)
3131

32-
find_header_files("${ARDUINO_CMAKE_PLATFORM_LIBRARIES_PATH}/${_library_name}/src" lib_headers)
33-
find_source_files("${ARDUINO_CMAKE_PLATFORM_LIBRARIES_PATH}/${_library_name}/src" lib_source_files)
32+
find_library_header_files("${ARDUINO_CMAKE_PLATFORM_LIBRARIES_PATH}/${_library_name}/src"
33+
lib_headers)
34+
find_library_source_files("${ARDUINO_CMAKE_PLATFORM_LIBRARIES_PATH}/${_library_name}/src"
35+
lib_source_files)
36+
3437
set(lib_sources ${lib_headers} ${lib_source_files})
3538

3639
_add_arduino_cmake_library(${_library_name} ${_board_id} "${lib_sources}")
3740

3841
endfunction()
3942

4043
#=============================================================================#
41-
# Links the given platform library target to the given target, be it an executable or another library.
44+
# Links the given platform library target to the given target.
4245
# _target_name - Name of the target to link against.
4346
# _library_name - Name of the library target to create, usually the platform library name.
4447
# _board_id - Board ID associated with the linked Core Lib.

examples/3rd-party-library/3rd_party.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
#include <Arduino.h>
22
#include "NeoPixelTest.hpp"
33
#include "GFXTest.h"
4+
#include "LiquidCrystalTest.hpp"
45

56
void setup()
67
{
78
testNeoPixel();
89
testGFX();
10+
testLiquidCrystal();
911
}
1012

1113
void loop()

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ get_board_id(board_id nano atmega328)
55

66
# First, declare and create our executable - It'll use 4 sources
77
add_arduino_executable(3rd_Party_Arduino_Library ${board_id} 3rd_party.cpp
8-
NeoPixelTest.cpp GFXTest.cpp)
8+
NeoPixelTest.cpp GFXTest.cpp LiquidCrystalTest.cpp)
99
target_include_directories(3rd_Party_Arduino_Library PRIVATE include)
1010

1111
# Add the "NeoPixel" library manually using the library addition API
@@ -21,7 +21,11 @@ target_source_directories(adafruit_GFX DIRS libraries/Adafruit-GFX-Library/Fonts
2121
# We can even automatically find a library that doesn't have a properties file!
2222
find_arduino_library(sky_writer Skywriter ${board_id} 3RD_PARTY)
2323

24+
# Libraries that have an inner-dependency on a platform library are also suported!
25+
find_arduino_library(liquid_Crystal LiquidCrystal_I2C ${board_id} 3RD_PARTY)
26+
2427
# Link all libraries to our previously created target
2528
link_arduino_library(3rd_Party_Arduino_Library adafruit_NeoPixel ${board_id})
2629
link_arduino_library(3rd_Party_Arduino_Library adafruit_GFX ${board_id})
2730
link_arduino_library(3rd_Party_Arduino_Library sky_writer ${board_id})
31+
link_arduino_library(3rd_Party_Arduino_Library liquid_Crystal ${board_id})
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#include "LiquidCrystalTest.hpp"
2+
3+
LiquidCrystal_I2C lcd(LCD_ADDRESS, LCD_COLUMNS, LCD_ROWS);
4+
5+
void testLiquidCrystal()
6+
{
7+
lcd.begin(LCD_COLUMNS, LCD_ROWS);
8+
lcd.clear();
9+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#ifndef EXAMPLES_LIQUIDCRYSTALTEST_HPP
2+
#define EXAMPLES_LIQUIDCRYSTALTEST_HPP
3+
4+
#include <LiquidCrystal_I2C.h>
5+
#include <Arduino.h>
6+
7+
#define LCD_ADDRESS 0x27
8+
#define LCD_COLUMNS 20
9+
#define LCD_ROWS 4
10+
11+
void testLiquidCrystal();
12+
13+
#endif //EXAMPLES_LIQUIDCRYSTALTEST_HPP

0 commit comments

Comments
 (0)