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

Commit e1eb024

Browse files
authored
Merge pull request #27 from arduino-cmake/feature/add-executable-fix
Fixed Executable API to handle unlimited list of sources
2 parents 3de14e1 + be73811 commit e1eb024

File tree

8 files changed

+29
-21
lines changed

8 files changed

+29
-21
lines changed

cmake/Platform/Targets/ArduinoExampleTarget.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function(add_arduino_example _target_name _board_id _example_name)
1414
find_arduino_example_sources("${ARDUINO_SDK_EXAMPLES_PATH}"
1515
${arduino_compliant_example_name} example_sketches ${ARGN})
1616
# First create the target (Without sources), then add sketches as converted sources
17-
add_arduino_executable(${_target_name} ${_board_id} "")
17+
add_arduino_executable(${_target_name} ${_board_id})
1818
target_sketches(${_target_name} ${_board_id} "${example_sketches}")
1919

2020
endfunction()
@@ -44,7 +44,7 @@ function(add_arduino_library_example _target_name _board_id
4444

4545
find_arduino_library_example_sources("${ARDUINO_SDK_LIBRARIES_PATH}/${arduino_compliant_library_name}"
4646
${arduino_compliant_example_name} example_sketches ${ARGN})
47-
add_arduino_executable(${_target_name} ${_board_id} "")
47+
add_arduino_executable(${_target_name} ${_board_id})
4848
target_sketches(${_target_name} ${_board_id} "${example_sketches}")
4949
link_arduino_library(${_target_name} ${_library_target_name} ${_board_id})
5050

cmake/Platform/Targets/ExecutableTarget.cmake

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
# using the given board ID and source files.
44
# _target_name - Name of the target (Executable) to create.
55
# _board_id - ID of the board to bind to the target (Each target can have a single board).
6-
# _src_files - List of source file (Could also be headers for code-inspection in some IDEs)
7-
# to create the executable from, just like it's done with a standard executable.
6+
# [Sources] - List of source files (Could also be headers for code-inspection in some IDEs)
7+
# to create the executable from, similar to CMake's built-in add_executable.
88
#=============================================================================#
9-
function(add_arduino_executable _target_name _board_id _src_files)
9+
function(add_arduino_executable _target_name _board_id)
1010

11-
add_executable(${_target_name} "${_src_files}")
11+
list(APPEND sources "${ARGN}") # Treat all remaining arguments as sources
12+
13+
add_executable(${_target_name} "${sources}")
1214
# Always add board's core lib
1315
add_arduino_core_lib(${_target_name} "${_board_id}")
1416
# Add compiler and linker flags

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ cmake_minimum_required(VERSION 3.8.2)
33
project(3rd_Party_Arduino_Library)
44
get_board_id(board_id nano atmega328)
55

6-
add_arduino_executable(3rd_Party_Arduino_Library ${board_id} testNeoPixel.cpp testGFX.cpp)
6+
add_arduino_executable(3rd_Party_Arduino_Library ${board_id} NeoPixelTest.cpp GFXTest.cpp)
7+
target_include_directories(3rd_Party_Arduino_Library PRIVATE include)
78

89
add_arduino_library(Adafruit_NeoPixel ${board_id} libraries/Adafruit_NeoPixel/Adafruit_NeoPixel.cpp)
910
target_include_directories(Adafruit_NeoPixel PUBLIC libraries/Adafruit_NeoPixel)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#include "include/GFXTest.h"
2+
3+
static Adafruit_GFX_Button gfxButton;
4+
5+
void doSomething()
6+
{
7+
gfxButton.isPressed();
8+
}

examples/3rd-party-library/testNeoPixel.cpp renamed to examples/3rd-party-library/NeoPixelTest.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
#include <Adafruit_NeoPixel.h>
2+
#include "GFXTest.h"
23

34
Adafruit_NeoPixel neoPixel;
45

56
void setup()
67
{
78
neoPixel.clear();
9+
doSomething();
810
}
911

1012
void loop()
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#ifndef EXAMPLES_GFXTEST_HPP
2+
#define EXAMPLES_GFXTEST_HPP
3+
4+
#include <Adafruit_GFX.h>
5+
6+
void doSomething();
7+
8+
#endif //EXAMPLES_GFXTEST_HPP

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

Lines changed: 0 additions & 13 deletions
This file was deleted.

examples/sketch/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ cmake_minimum_required(VERSION 3.8)
33
project(Sketch LANGUAGES C CXX ASM)
44
get_board_id(board_id nano atmega328)
55

6-
add_arduino_executable(Sketch ${board_id} "")
6+
add_arduino_executable(Sketch ${board_id})
77
target_sketches(Sketch ${board_id} sketch.ino)

0 commit comments

Comments
 (0)