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

Commit 9513432

Browse files
committed
Added a header-only library example using dummy-created library.
1 parent 76fcb99 commit 9513432

File tree

5 files changed

+52
-0
lines changed

5 files changed

+52
-0
lines changed

examples/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ project(Examples LANGUAGES C CXX ASM)
55
add_subdirectory(hello-world)
66
add_subdirectory(arduino-library)
77
add_subdirectory(3rd-party-library)
8+
add_subdirectory(header-only-library)
89
add_subdirectory(blink-example)
910
add_subdirectory(servo-knob-example)
1011
add_subdirectory(sketch)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
cmake_minimum_required(VERSION 3.8.2)
2+
3+
project(Header_Only_Lib)
4+
get_board_id(board_id nano atmega328)
5+
6+
add_arduino_executable(Header_Only_Lib ${board_id} headerOnlyTest.cpp)
7+
8+
# Find the library by 'tricking' the framework to use current directory as the Sketchbook path,
9+
# allowing us to use the 'find' API
10+
set(ARDUINO_CMAKE_SKETCHBOOK_PATH "${CMAKE_CURRENT_LIST_DIR}")
11+
find_arduino_library(headerTest test-lib ${board_id} 3RD_PARTY HEADER_ONLY)
12+
13+
link_arduino_library(Header_Only_Lib headerTest ${board_id} HEADER_ONLY)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include <Arduino.h>
2+
#include <TestLib.hpp>
3+
4+
void setup()
5+
{
6+
pinMode(BAR, OUTPUT);
7+
}
8+
9+
void loop()
10+
{
11+
foo();
12+
delayMicroseconds(SOME_DELAY);
13+
}
14+
15+
void foo()
16+
{
17+
digitalWrite(BAR, HIGH);
18+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name=Test Library
2+
version=0.1
3+
author=Arduino-CMake-NG
4+
maintainer=Arduino-CMake-NG <https://github.com/arduino-cmake/Arduino-CMake-NG>
5+
sentence=Arduino library to test header-only feature support in the Arduino-CMake framework
6+
paragraph=Arduino library to test header-only feature support in the Arduino-CMake framework
7+
category=Display
8+
url=https://github.com/arduino-cmake/Arduino-CMake-NG
9+
architectures=*
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#ifndef EXAMPLES_TESTLIB_HPP
2+
#define EXAMPLES_TESTLIB_HPP
3+
4+
#include <Arduino.h>
5+
6+
#define BAR 1
7+
#define SOME_DELAY 200
8+
9+
void foo();
10+
11+
#endif //EXAMPLES_TESTLIB_HPP

0 commit comments

Comments
 (0)