Skip to content

Commit 4a5ae09

Browse files
committed
finishing first working phase of cmake support
1 parent 8e2cdc6 commit 4a5ae09

37 files changed

+224
-145
lines changed

external/flux_sdk_import.cmake

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
1-
# ##############################################################################
1+
# ##################################################################################################
22
# include/import file for the flux-sdk cmake system
3-
# ##############################################################################
3+
# ##################################################################################################
44

5-
# we are just using this as a manifest system, so doing the best to bypass the
6-
# compiler detection
5+
# we are just using this as a manifest system, so doing the best to bypass the compiler detection
76
set(CMAKE_C_COMPILER_FORCED TRUE)
87
set(CMAKE_CXX_COMPILER_FORCED TRUE)
98

10-
# Where is the flux-sdk directory? This should be in some "include file from the
11-
# sdk"
9+
# Where is the flux-sdk directory? This should be in some "include file from the sdk"
1210

13-
if(NOT FLUX_SDK_PATH)
14-
if(DEFINED ENV{FLUX_SDK_PATH})
15-
set(FLUX_SDK_PATH $ENV{FLUX_SDK_PATH})
16-
elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../flux-sdk)
17-
set(FLUX_SDK_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../flux-sdk)
18-
endif()
19-
endif()
11+
if (NOT FLUX_SDK_PATH)
12+
if (DEFINED ENV{FLUX_SDK_PATH})
13+
set(FLUX_SDK_PATH $ENV{FLUX_SDK_PATH})
14+
elseif (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../flux-sdk)
15+
set(FLUX_SDK_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../flux-sdk)
16+
endif ()
17+
endif ()
2018

2119
# crawl the flux-sdk directory and add all the subdirectories
2220
include(${FLUX_SDK_PATH}/flux_sdk_init.cmake)

flux_sdk_init.cmake

Lines changed: 135 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -1,154 +1,170 @@
11
# @file: flux_sdk_init.cmake
22

3-
# ##############################################################################
3+
# ##################################################################################################
44
# flux_sdk_version()
55
include(${CMAKE_CURRENT_LIST_DIR}/flux_sdk_version.cmake)
66

7-
# ##############################################################################
7+
# ##################################################################################################
8+
# flux_sdk_set_platform()
9+
#
10+
# Set the platform for the SDK - what hardware stack is this used on?
11+
#
12+
macro (flux_sdk_set_platform platform)
13+
set(FLUX_SDK_PLATFORM ${platform})
14+
message("Platform:\t${FLUX_SDK_PLATFORM}")
15+
endmacro ()
16+
17+
# ##################################################################################################
818
# flux_sdk_set_project_directory()
919
#
10-
macro(flux_sdk_set_project_directory project_directory)
20+
macro (flux_sdk_set_project_directory project_directory)
1121

12-
set(PROJECT_FLUX_DIRECTORY
13-
${CMAKE_CURRENT_SOURCE_DIR}/${project_directory}/Flux)
22+
set(PROJECT_FLUX_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${project_directory}/Flux)
1423

15-
if(NOT EXISTS ${PROJECT_FLUX_DIRECTORY})
16-
message(STATUS "Creating directory: ${PROJECT_FLUX_DIRECTORY}")
17-
file(MAKE_DIRECTORY ${PROJECT_FLUX_DIRECTORY})
18-
endif()
24+
if (NOT EXISTS ${PROJECT_FLUX_DIRECTORY})
25+
message(STATUS "Creating directory: ${PROJECT_FLUX_DIRECTORY}")
26+
file(MAKE_DIRECTORY ${PROJECT_FLUX_DIRECTORY})
27+
endif ()
1928

20-
endmacro()
21-
# ##############################################################################
29+
endmacro ()
30+
# ##################################################################################################
2231
# flux_sdk_add_module()
2332
#
2433
# macro to add "modules" to our list of modules to add to the build
25-
macro(flux_sdk_add_module)
26-
set(list_var "${ARGN}")
27-
foreach(arg IN LISTS list_var)
28-
list(APPEND FLUX_MODULES_TO_ADD ${arg})
29-
endforeach()
30-
endmacro()
31-
32-
function(flux_sdk_get_directory_name result_name)
33-
get_filename_component(THIS_MODULE ${CMAKE_CURRENT_SOURCE_DIR} NAME)
34-
set(${result_name}
35-
${THIS_MODULE}
36-
PARENT_SCOPE)
37-
endfunction()
38-
39-
# ##############################################################################
34+
macro (flux_sdk_add_module)
35+
set(list_var "${ARGN}")
36+
foreach (arg IN LISTS list_var)
37+
list(APPEND FLUX_MODULES_TO_ADD ${arg})
38+
endforeach ()
39+
endmacro ()
40+
41+
function (flux_sdk_get_directory_name result_name)
42+
get_filename_component(THIS_MODULE ${CMAKE_CURRENT_SOURCE_DIR} NAME)
43+
set(${result_name}
44+
${THIS_MODULE}
45+
PARENT_SCOPE)
46+
endfunction ()
47+
48+
# ##################################################################################################
4049
# flux_sdk_add_source_files()
4150
#
4251
# Macro to add a file to our build system file list
43-
macro(flux_sdk_add_source_files)
44-
set(list_var "${ARGN}")
45-
foreach(arg IN LISTS list_var)
46-
configure_file(${arg} ${PROJECT_FLUX_DIRECTORY} COPYONLY)
47-
endforeach()
48-
endmacro()
49-
50-
# ##############################################################################
52+
macro (flux_sdk_add_source_files)
53+
set(list_var "${ARGN}")
54+
foreach (arg IN LISTS list_var)
55+
configure_file(${arg} ${PROJECT_FLUX_DIRECTORY} COPYONLY)
56+
endforeach ()
57+
endmacro ()
58+
59+
# ##################################################################################################
5160
# flux_sdk_is_module_enabled()
5261
#
53-
# Define a function that will check if a module is enabled in the list of
54-
# enabled modules
55-
56-
function(flux_sdk_is_module_enabled module_name result)
57-
if(${module_name} IN_LIST FLUX_MODULES_TO_ADD)
58-
set(${result}
59-
TRUE
60-
PARENT_SCOPE)
61-
else()
62-
set(${result}
63-
FALSE
64-
PARENT_SCOPE)
65-
endif()
66-
endfunction()
67-
68-
# ##############################################################################
62+
# Define a function that will check if a module is enabled in the list of enabled modules
63+
64+
function (flux_sdk_is_module_enabled module_name result)
65+
if (${module_name} IN_LIST FLUX_MODULES_TO_ADD)
66+
set(${result}
67+
TRUE
68+
PARENT_SCOPE)
69+
else ()
70+
set(${result}
71+
FALSE
72+
PARENT_SCOPE)
73+
endif ()
74+
endfunction ()
75+
76+
# ##################################################################################################
6977
# flux_sdk_process_subdirectories()
7078
#
71-
# Define a function that will cacade down subdirectories if that directory is a
72-
# module desired, and has a CMakeLists.txt file.
79+
# Define a function that will cacade down subdirectories if that directory is a module desired, and
80+
# has a CMakeLists.txt file.
7381
#
74-
# Note: If the <directory>_all_modules flag is set, then all submodules of that
75-
# directory will be processed
82+
# Note: If the <directory>_all_modules flag is set, then all submodules of that directory will be
83+
# processed
7684

77-
function(flux_sdk_process_subdirectories)
85+
function (flux_sdk_process_subdirectories)
7886

79-
# get our place in the SDK - print a value
80-
file(RELATIVE_PATH local_path ${FLUX_SDK_PATH} ${CMAKE_CURRENT_SOURCE_DIR})
81-
message("Processing:\t\$FLUX_SDK/${local_path}")
87+
# get our place in the SDK - print a value
88+
file(RELATIVE_PATH local_path ${FLUX_SDK_PATH} ${CMAKE_CURRENT_SOURCE_DIR})
89+
message("Processing:\t\$FLUX_SDK/${local_path}")
8290

83-
# Get the name of the current directory - basename. We use this to build our
84-
# "all submodules" flag for this directory
85-
get_filename_component(CurrentDir ${CMAKE_CURRENT_SOURCE_DIR} NAME)
86-
set(all_modules_flag "${CurrentDir}_all_modules")
91+
# Get the name of the current directory - basename. We use this to build our "all submodules"
92+
# flag for this directory
93+
get_filename_component(CurrentDir ${CMAKE_CURRENT_SOURCE_DIR} NAME)
94+
set(all_modules_flag "${CurrentDir}_all_modules")
8795

88-
# is the flag set?
89-
flux_sdk_is_module_enabled(${all_modules_flag} process_all_submodules)
96+
# is the flag set?
97+
flux_sdk_is_module_enabled(${all_modules_flag} process_all_submodules)
9098

91-
# is everything enabled?
92-
flux_sdk_is_module_enabled(flux_all_modules process_all_modules)
99+
# is everything enabled?
100+
flux_sdk_is_module_enabled(flux_all_modules process_all_modules)
93101

94-
message("Module flag:\t${all_modules_flag} = ${process_all_submodules}")
102+
message("Module flag:\t${all_modules_flag} = ${process_all_submodules}")
95103

96-
# are we loading all submodules?
97-
if(process_all_submodules OR process_all_modules)
98-
set(load_all_modules TRUE)
99-
endif()
104+
# are we loading all submodules?
105+
if (process_all_submodules OR process_all_modules)
106+
set(load_all_modules TRUE)
107+
endif ()
100108

101-
# Get all the children of this directory
102-
file(
103-
GLOB children
104-
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
105-
${CMAKE_CURRENT_SOURCE_DIR}/*)
109+
# Get all the children of this directory
110+
file(
111+
GLOB children
112+
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
113+
${CMAKE_CURRENT_SOURCE_DIR}/*)
106114

107-
# Iterate over all the children
108-
foreach(child ${children})
115+
# Iterate over all the children
116+
foreach (child ${children})
109117

110-
# Sanity check
111-
if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${child}
112-
AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${child}/CMakeLists.txt)
118+
# Sanity check
119+
if (IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${child}
120+
AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${child}/CMakeLists.txt)
113121

114-
# add this module - in list, or all devices flag set
115-
if(load_all_modules OR ${child} IN_LIST FLUX_MODULES_TO_ADD)
116-
message(STATUS "Adding: ${child}")
117-
add_subdirectory(${child})
118-
endif()
119-
endif()
120-
endforeach()
121-
message("")
122-
endfunction()
122+
# add this module - in list, or all devices flag set
123+
if (load_all_modules OR ${child} IN_LIST FLUX_MODULES_TO_ADD)
124+
message(STATUS "Adding: ${child}")
125+
add_subdirectory(${child})
126+
endif ()
127+
endif ()
128+
endforeach ()
129+
message("")
130+
endfunction ()
123131

124-
# ##############################################################################
132+
# ##################################################################################################
125133
# flux_sdk_init()
126134
#
127-
# Called to start the SDK build process. This should be called after the
128-
# flux_sdk import cmake file is loaded (of course)
129-
macro(flux_sdk_init)
130-
if(NOT CMAKE_PROJECT_NAME)
131-
message(
132-
WARNING "flux_sdk_init() should be called after the project is created")
133-
endif()
134-
135-
# write some info!
136-
message("\n-----------------------------------------------------")
137-
message("SparkFun Flux SDK - Version: ${FLUX_SDK_VERSION}")
138-
message("-----------------------------------------------------\n")
139-
message("SDK Path:\t${FLUX_SDK_PATH}")
140-
message("Project Name:\t${CMAKE_PROJECT_NAME}")
141-
message("Destination:\t${PROJECT_FLUX_DIRECTORY}")
142-
message("")
143-
144-
# is everything enabled?
145-
flux_sdk_is_module_enabled(flux_all_modules process_all_modules)
146-
message("Module flag:\tflux_all_modules = ${process_all_modules}")
147-
string(TIMESTAMP COMPILE_TIME "%Y-%m-%d %H:%M:%S")
148-
message("Build Time:\t${COMPILE_TIME}")
149-
message("")
150-
151-
# load the root directory of the SDK
152-
add_subdirectory(${FLUX_SDK_PATH} flux-sdk)
153-
154-
endmacro()
135+
# Called to start the SDK build process. This should be called after the flux_sdk import cmake file
136+
# is loaded (of course)
137+
macro (flux_sdk_init)
138+
if (NOT CMAKE_PROJECT_NAME)
139+
message(WARNING "flux_sdk_init() should be called after the project is created")
140+
endif ()
141+
142+
# write some info!
143+
message("\n-----------------------------------------------------")
144+
message("SparkFun Flux SDK - Version: ${FLUX_SDK_VERSION}")
145+
message("-----------------------------------------------------\n")
146+
message("SDK Path:\t${FLUX_SDK_PATH}")
147+
message("Project Name:\t${CMAKE_PROJECT_NAME}")
148+
message("Destination:\t${PROJECT_FLUX_DIRECTORY}")
149+
message("")
150+
151+
# is everything enabled?
152+
flux_sdk_is_module_enabled(flux_all_modules process_all_modules)
153+
message("Module flag:\tflux_all_modules = ${process_all_modules}")
154+
155+
if (NOT DEFINED FLUX_SDK_PLATFORM)
156+
message(
157+
FATAL_ERROR
158+
"No platform specified. Set the target platform using `flux_sdk_set_platform()` in your projects CMakeLists.txt file"
159+
)
160+
endif ()
161+
message("Platform:\t${FLUX_SDK_PLATFORM}")
162+
163+
string(TIMESTAMP COMPILE_TIME "%Y-%m-%d %H:%M:%S")
164+
message("Build Time:\t${COMPILE_TIME}")
165+
message("")
166+
167+
# load the root directory of the SDK
168+
add_subdirectory(${FLUX_SDK_PATH} flux-sdk)
169+
170+
endmacro ()

src/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
# just add our subdirectories -- recurse down the tree
22
add_subdirectory(core)
33
add_subdirectory(device)
4+
add_subdirectory(iot)
5+
add_subdirectory(net)
6+
add_subdirectory(platform)

src/core/flux_base/CMakeLists.txt

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,32 @@
1-
21
# Add the source files for this directory
3-
flux_sdk_add_source_files(flxBusI2C.cpp flxBusI2C.h flxBusSPI.cpp flxBusSPI.h flxCore.cpp flxCore.h flxCoreDevice.cpp
4-
flxCoreDevice.h flxCoreEvent.h flxCoreEvent.cpp flxCoreEventID.h flxCoreInterface.h flxCoreJobs.cpp flxCoreJobs.h
5-
flxCoreLog.cpp flxCoreLog.h flxCoreMsg.cpp flxCoreMsg.h flxCoreParam.h flxCoreProps.h flxCoreTypes.h flxDevice.h
6-
flxFlux.h flxSerial.cpp flxSerial.h flxTimer.h flxUtils.cpp flxUtils.h spSpark.cpp)
2+
flux_sdk_add_source_files(
3+
Flux.h
4+
flxBusI2C.cpp
5+
flxBusI2C.h
6+
flxBusSPI.cpp
7+
flxBusSPI.h
8+
flxCore.cpp
9+
flxCore.h
10+
flxCoreDevice.cpp
11+
flxCoreDevice.h
12+
flxCoreEvent.h
13+
flxCoreEvent.cpp
14+
flxCoreEventID.h
15+
flxCoreInterface.h
16+
flxCoreJobs.cpp
17+
flxCoreJobs.h
18+
flxCoreLog.cpp
19+
flxCoreLog.h
20+
flxCoreMsg.cpp
21+
flxCoreMsg.h
22+
flxCoreParam.h
23+
flxCoreProps.h
24+
flxCoreTypes.h
25+
flxDevice.h
26+
flxFlux.h
27+
flxSerial.cpp
28+
flxSerial.h
29+
flxTimer.h
30+
flxUtils.cpp
31+
flxUtils.h
32+
spSpark.cpp)

src/Flux.h renamed to src/core/flux_base/Flux.h

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

1717
#pragma once
1818

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

src/core/flux_file/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Add the source files for this directory
2+
flux_sdk_add_source_files(flxFileRotate.h flxFileRotate.cpp flxFS.h)
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/core/flux_logging/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
21
# Add the source files for this directory
3-
flux_sdk_add_source_files(flxFmtCSV.h flxFmtJSON.h flxLogger.cpp flxLogger.h)
2+
flux_sdk_add_source_files(flxFmtCSV.h flxFmtJSON.h flxLogger.cpp flxLogger.h flxOutput.h)

0 commit comments

Comments
 (0)