-
Notifications
You must be signed in to change notification settings - Fork 9
/
CMakeLists.txt
123 lines (106 loc) · 6.29 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
cmake_minimum_required(VERSION 3.15)
project(CircuitOS)
set(PORT /dev/ttyUSB0)
set(DEVICE cm:esp32:spencer) # Arduino device FQBN
set(CMAKE_CXX_STANDARD 17)
if(WIN32 OR CYGWIN)
set(Arduino15 $ENV{APPDATA}/../Local/Arduino15)
set(ArduinoLibs $ENV{USERPROFILE}/Documents/Arduino/libraries)
string(REPLACE "\\" "/" Arduino15 ${Arduino15})
string(REPLACE "\\" "/" ArduinoLibs ${ArduinoLibs})
if(${CYGWIN})
string(REGEX REPLACE "^([A-Za-z]):" "/cygdrive/\\1" Arduino15 ${Arduino15})
string(REGEX REPLACE "^([A-Za-z]):" "/cygdrive/\\1" ArduinoLibs ${ArduinoLibs})
endif()
else()
set(Arduino15 ~/.arduino15)
set(ArduinoLibs /mnt/c/Users/emilg/Documents/Arduino/libraries)
endif()
# ESP32
include_directories(${Arduino15}/packages/cm/hardware/esp32/1.7.3/cores/esp32)
include_directories(${Arduino15}/packages/cm/hardware/esp32/1.7.3/tools/sdk)
include_directories(${Arduino15}/packages/cm/hardware/esp32/1.7.3/tools/sdk/include)
include_directories(${Arduino15}/packages/cm/hardware/esp32/1.7.3/tools/sdk/include/esp32)
include_directories(${Arduino15}/packages/cm/hardware/esp32/1.7.3/tools/sdk/include/freertos)
include_directories(${Arduino15}/packages/cm/hardware/esp32/1.7.3/tools/sdk/include/spi_flash)
include_directories(${Arduino15}/packages/cm/hardware/esp32/1.7.3/tools/sdk/include/nvs_flash)
include_directories(${Arduino15}/packages/cm/hardware/esp32/1.7.3/tools/sdk/include/log)
include_directories(${Arduino15}/packages/cm/hardware/esp32/1.7.3/tools/sdk/include/bootloader_support)
include_directories(${Arduino15}/packages/cm/hardware/esp32/1.7.3/tools/sdk/include/driver)
include_directories(${Arduino15}/packages/cm/hardware/esp32/1.7.3/tools/sdk/include/driver/driver)
include_directories(${Arduino15}/packages/cm/hardware/esp32/1.7.3/tools/sdk/include/soc)
# ESP8266
include_directories(${Arduino15}/packages/esp8266/hardware/esp8266/2.7.1/cores/esp8266)
include_directories(${Arduino15}/packages/esp8266/hardware/esp8266/2.7.1/libraries/LittleFS/src)
include_directories(${Arduino15}/packages/cm/hardware/esp8266/1.0.1/cores/esp8266)
include_directories(${Arduino15}/packages/cm/hardware/esp8266/1.0.1/libraries/Nibble/src)
include_directories(${Arduino15}/packages/cm/hardware/esp8266/1.0.1/libraries/CircuitOS/src)
include_directories(${Arduino15}/packages/cm/hardware/esp8266/1.0.1/libraries/TFT_eSPI)
include_directories(${Arduino15}/packages/cm/hardware/esp8266/1.0.1/libraries/TFT_eSPI/Extensions)
include_directories(${Arduino15}/packages/cm/hardware/esp8266/1.0.1/libraries/FS)
include_directories(${Arduino15}/packages/cm/hardware/esp8266/1.0.1/cores/esp8266/FS)
include_directories(${Arduino15}/packages/cm/hardware/esp8266/1.0.1/libraries/LittleFS/src)
include_directories(${Arduino15}/packages/cm/hardware/esp8266/1.0.1/libraries/Wire)
include_directories(${Arduino15}/packages/cm/hardware/esp8266/1.0.1/cores/esp8266/avr)
include_directories(${Arduino15}/packages/cm/hardware/esp8266/1.0.1/libraries/heatshrink)
include_directories(${Arduino15}/packages/cm/hardware/esp8266/1.0.1/libraries/ESP8266WiFi/src)
# Package libs
include_directories(${Arduino15}/packages/cm/hardware/esp32/1.7.3/libraries/Wire/src)
include_directories(${Arduino15}/packages/cm/hardware/esp32/1.7.3/libraries/FS/src)
include_directories(${Arduino15}/packages/cm/hardware/esp32/1.7.3/libraries/SD/src)
include_directories(${Arduino15}/packages/cm/hardware/esp32/1.7.3/libraries/SPI/src)
include_directories(${Arduino15}/packages/cm/hardware/esp32/1.7.3/libraries/WiFi/src)
include_directories(${Arduino15}/packages/cm/hardware/esp32/1.7.3/libraries/SPIFFS/src)
include_directories(${Arduino15}/packages/cm/hardware/esp32/1.7.3/libraries/HTTPClient/src)
include_directories(${Arduino15}/packages/cm/hardware/esp32/1.7.3/libraries/TFT_eSPI)
include_directories(${Arduino15}/packages/cm/hardware/esp32/1.7.3/libraries/TFT_eSPI/Extensions)
include_directories(${Arduino15}/packages/cm/hardware/esp32/1.7.3/libraries/heatshrink)
# External libs
include_directories(${ArduinoLibs}/Keypad_I2Ca)
include_directories(${ArduinoLibs}/Keypad/src)
include_directories(${ArduinoLibs}/I2Cdev)
include_directories(${ArduinoLibs}/MPU6050)
include_directories(${ArduinoLibs}/SparkFun_ICM20948/src)
include_directories(${ArduinoLibs}/lvgl/src)
AUX_SOURCE_DIRECTORY(src SOURCES)
AUX_SOURCE_DIRECTORY(src/Audio SOURCES)
AUX_SOURCE_DIRECTORY(src/Bitmaps SOURCES)
AUX_SOURCE_DIRECTORY(src/Buffer SOURCES)
AUX_SOURCE_DIRECTORY(src/Devices SOURCES)
AUX_SOURCE_DIRECTORY(src/Devices/Motion SOURCES)
AUX_SOURCE_DIRECTORY(src/Devices/SerialFlash SOURCES)
AUX_SOURCE_DIRECTORY(src/Devices/Matrix SOURCES)
AUX_SOURCE_DIRECTORY(src/Display SOURCES)
AUX_SOURCE_DIRECTORY(src/Elements SOURCES)
AUX_SOURCE_DIRECTORY(src/FS SOURCES)
AUX_SOURCE_DIRECTORY(src/Input SOURCES)
AUX_SOURCE_DIRECTORY(src/Loop SOURCES)
AUX_SOURCE_DIRECTORY(src/Motion SOURCES)
set(SOURCES ${SOURCES} src/Motion/Fusion.hpp)
AUX_SOURCE_DIRECTORY(src/Support SOURCES)
AUX_SOURCE_DIRECTORY(src/Sync SOURCES)
AUX_SOURCE_DIRECTORY(src/UI SOURCES)
AUX_SOURCE_DIRECTORY(src/Util SOURCES)
AUX_SOURCE_DIRECTORY(src/Network SOURCES)
add_definitions(-DDEBUG)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/build)
set(BUILD ${ROOT}/build)
SET_SOURCE_FILES_PROPERTIES(${CMAKE_PROJECT_NAME}.ino PROPERTIES LANGUAGE CXX)
add_custom_command(OUTPUT ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_PROJECT_NAME}.ino.elf
COMMAND arduino-cli compile --fqbn ${DEVICE} --output-dir ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ${CMAKE_SOURCE_DIR}
DEPENDS ${CMAKE_PROJECT_NAME}.ino ${SOURCES}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
add_custom_target(CMBuild
SOURCES ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_PROJECT_NAME}.ino.elf)
add_custom_target(CMUpload ALL
COMMAND arduino-cli upload --fqbn ${DEVICE} -p ${PORT} --input-dir ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
DEPENDS CMBuild
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
add_executable(${CMAKE_PROJECT_NAME}.bin ${CMAKE_PROJECT_NAME}.ino ${SOURCES})
set(EXAMPLES ListMenu Settings Mutex Queue Motion)
foreach(EXAMPLE ${EXAMPLES})
AUX_SOURCE_DIRECTORY(examples/${EXAMPLE} EXAMPLE_SOURCES)
AUX_SOURCE_DIRECTORY(examples/${EXAMPLE}/src EXAMPLE_SOURCES)
SET_SOURCE_FILES_PROPERTIES(examples/${EXAMPLE}/${EXAMPLE}.ino PROPERTIES LANGUAGE CXX)
add_executable(Example_${EXAMPLE} ${EXAMPLE_SOURCES} examples/${EXAMPLE}/${EXAMPLE}.ino)
endforeach(EXAMPLE)