-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
87 lines (69 loc) · 4.04 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
cmake_minimum_required(VERSION 3.20)
project(Batmobile-Firmware)
set(PORT COM3)
set(DEVICE cm:esp32:batmobile)
set(CMAKE_CXX_STANDARD 17)
set(ROOT ${CMAKE_SOURCE_DIR})
if (WIN32 OR CYGWIN)
set(Arduino15 $ENV{APPDATA}/../Local/Arduino15)
set(ArduinoLibs $ENV{USERPROFILE}/OneDrive/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})
string(REGEX REPLACE "^/cygdrive/([A-Za-z])" "\\1:/" ROOT ${ROOT})
endif ()
else ()
set(Arduino15 ~/.arduino15)
set(ArduinoLibs ~/Arduino/libraries)
endif ()
include_directories(${Arduino15}/packages/cm/hardware/esp32/1.6.2/cores/esp32)
include_directories(${Arduino15}/packages/cm/hardware/esp32/1.6.2/tools/sdk)
include_directories(${Arduino15}/packages/cm/hardware/esp32/1.6.2/tools/sdk/include)
include_directories(${Arduino15}/packages/cm/hardware/esp32/1.6.2/tools/sdk/include/esp32)
include_directories(${Arduino15}/packages/cm/hardware/esp32/1.6.2/tools/sdk/include/freertos)
include_directories(${Arduino15}/packages/cm/hardware/esp32/1.6.2/tools/sdk/include/spi_flash)
include_directories(${Arduino15}/packages/cm/hardware/esp32/1.6.2/tools/sdk/include/nvs_flash)
include_directories(${Arduino15}/packages/cm/hardware/esp32/1.6.2/tools/sdk/include/driver)
include_directories(${Arduino15}/packages/cm/hardware/esp32/1.6.2/tools/sdk/include/driver/driver)
# Include directories
include_directories(${Arduino15}/packages/cm/hardware/esp32/1.6.2/libraries/Wire/src)
include_directories(${Arduino15}/packages/cm/hardware/esp32/1.6.2/libraries/FS/src)
include_directories(${Arduino15}/packages/cm/hardware/esp32/1.6.2/libraries/SD/src)
include_directories(${Arduino15}/packages/cm/hardware/esp32/1.6.2/libraries/SPI/src)
include_directories(${Arduino15}/packages/cm/hardware/esp32/1.6.2/libraries/WiFi/src)
include_directories(${Arduino15}/packages/cm/hardware/esp32/1.6.2/libraries/SPIFFS/src)
include_directories(${Arduino15}/packages/cm/hardware/esp32/1.6.2/libraries/JPEGDecoder/src)
include_directories(${Arduino15}/packages/cm/hardware/esp32/1.6.2/libraries/OpenCV-ESP32/src)
include_directories(${Arduino15}/packages/cm/hardware/esp32/1.6.2/libraries/Update/src)
include_directories(${Arduino15}/packages/cm/hardware/esp32/1.6.2/libraries/CircuitOS/src)
include_directories(${Arduino15}/packages/cm/hardware/esp32/1.6.2/libraries/glm)
include_directories(${Arduino15}/packages/cm/hardware/esp32/1.6.2/libraries/AsyncUDP/src)
include_directories(${Arduino15}/packages/cm/hardware/esp32/1.6.2/libraries/AsyncTCP/src)
include_directories(${ArduinoLibs}/Batmobile-Library/src)
include_directories(${ArduinoLibs}/Batmobile-Common/src)
# Source directories
file(GLOB_RECURSE SOURCES "src/**.cpp" "src/**.c" "src/**.hpp" "src/**.h")
# Defines
add_definitions(-DDEBUG)
add_definitions(-DESP32)
add_definitions(-DCIRCUITOS_FREERTOS)
add_definitions(-DCIRCUITOS_NVS)
add_definitions(-DCIRCUITOS_LOVYANGFX)
add_definitions(-DCIRCUITOS_PIEZO_ESP32)
add_definitions(-DCIRCUITOS_PIEZO_ESP32_PWM_CHANNEL=0)
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_PROJECT_NAME}.ino
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 -v --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})