-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
58 lines (46 loc) · 2.39 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
cmake_minimum_required(VERSION 3.15)
project(Nibble-Launcher)
set(PORT /dev/ttyUSB0)
set(DEVICE cm:esp8266:nibble)
set(CMAKE_CXX_STANDARD 11)
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 ~/Arduino/libraries)
endif()
include_directories(${Arduino15}/packages/cm/hardware/esp8266/1.0.1/cores/esp8266)
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/Nibble/src)
include_directories(${Arduino15}/packages/cm/hardware/esp8266/1.0.1/libraries/ESP8266WiFi/src)
AUX_SOURCE_DIRECTORY(src SOURCES)
AUX_SOURCE_DIRECTORY(src/Elements SOURCES)
AUX_SOURCE_DIRECTORY(src/SettingsMenu SOURCES)
AUX_SOURCE_DIRECTORY(src/SettingsMenu/Elements SOURCES)
AUX_SOURCE_DIRECTORY(src/Services SOURCES)
add_definitions(-DDEBUG)
add_definitions(-DCIRCUITOS_LITTLEFS)
add_definitions(-DCIRCUITOS_TONE)
add_definitions(-DCIRCUITOS_LOWRAM)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/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 -v 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 --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})