Skip to content

Commit fb3458f

Browse files
committed
Mods to work as Arduino library
Because of arduino needs - grr- the results of cmake needs to dump out a basic Arduino library - that acts like the original SparkFun_Flux Arduino library. This is needed to use the --library flag with arduino-cli and have the linker work correctly ...
1 parent 4a5ae09 commit fb3458f

File tree

4 files changed

+21
-9
lines changed

4 files changed

+21
-9
lines changed

CMakeLists.txt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
21
# $id$ FLUX_SDK_PATH/CMakeLists.txt
32
#
4-
# just cascade down to src
53

6-
add_subdirectory(src)
4+
# we are building a "fake" Arduino library so we can compile the code using arduino-cli. This
5+
# requires a library.properties file in the root of the project. This file i
6+
configure_file(library.properties ${PROJECT_FLUX_DIRECTORY} COPYONLY)
7+
8+
# Now just cascade down to src
9+
10+
add_subdirectory(src)

flux_sdk_init.cmake

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,18 @@ endmacro ()
1919
#
2020
macro (flux_sdk_set_project_directory project_directory)
2121

22-
set(PROJECT_FLUX_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${project_directory}/Flux)
22+
set(PROJECT_FLUX_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${project_directory}/SparkFun_Flux)
2323

2424
if (NOT EXISTS ${PROJECT_FLUX_DIRECTORY})
2525
message(STATUS "Creating directory: ${PROJECT_FLUX_DIRECTORY}")
2626
file(MAKE_DIRECTORY ${PROJECT_FLUX_DIRECTORY})
2727
endif ()
28+
if (NOT EXISTS ${PROJECT_FLUX_DIRECTORY}/src)
29+
file(MAKE_DIRECTORY ${PROJECT_FLUX_DIRECTORY}/src)
30+
endif ()
31+
if (NOT EXISTS ${PROJECT_FLUX_DIRECTORY}/src/Flux)
32+
file(MAKE_DIRECTORY ${PROJECT_FLUX_DIRECTORY}/src/Flux)
33+
endif ()
2834

2935
endmacro ()
3036
# ##################################################################################################
@@ -52,7 +58,7 @@ endfunction ()
5258
macro (flux_sdk_add_source_files)
5359
set(list_var "${ARGN}")
5460
foreach (arg IN LISTS list_var)
55-
configure_file(${arg} ${PROJECT_FLUX_DIRECTORY} COPYONLY)
61+
configure_file(${arg} ${PROJECT_FLUX_DIRECTORY}/src/Flux COPYONLY)
5662
endforeach ()
5763
endmacro ()
5864

src/core/flux_base/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Add the source files for this directory
22
flux_sdk_add_source_files(
3-
Flux.h
43
flxBusI2C.cpp
54
flxBusI2C.h
65
flxBusSPI.cpp
@@ -30,3 +29,6 @@ flux_sdk_add_source_files(
3029
flxUtils.cpp
3130
flxUtils.h
3231
spSpark.cpp)
32+
33+
# the flux include file is special - its our hook for the Arduino "library" being created
34+
configure_file(Flux.h ${PROJECT_FLUX_DIRECTORY}/src COPYONLY)

src/core/flux_base/Flux.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@
1616

1717
#pragma once
1818

19-
#include "flxCore.h"
20-
#include "flxDevice.h"
21-
#include "flxFlux.h"
19+
#include "Flux/flxCore.h"
20+
#include "Flux/flxDevice.h"
21+
#include "Flux/flxFlux.h"

0 commit comments

Comments
 (0)