-
Notifications
You must be signed in to change notification settings - Fork 49
/
CMakeLists.txt
237 lines (219 loc) · 5.58 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
# == DO NEVER EDIT THE NEXT LINES for Raspberry Pi Pico VS Code Extension to work ==
if(WIN32)
set(USERHOME $ENV{USERPROFILE})
else()
set(USERHOME $ENV{HOME})
endif()
set(sdkVersion 2.0.0)
set(toolchainVersion 13_2_Rel1)
set(picotoolVersion 2.0.0)
set(picoVscode ${USERHOME}/.pico-sdk/cmake/pico-vscode.cmake)
if (EXISTS ${picoVscode})
include(${picoVscode})
endif()
# ====================================================================================
cmake_minimum_required(VERSION 3.13)
option(ADD_HPGL "Add HPGL plugin" OFF)
# Note: WiFi and Ethernet cannot be enabled at the same time!
option(ADD_WIFI "Add WiFi networking" OFF)
option(ADD_ETHERNET "Add Ethernet networking" OFF)
option(ADD_BLUETOOTH "Add Bluetooth" OFF)
# Set LWIP_DIR below to the root path of lwIP sources when the following is set ON!
option(ADD_mDNS "Add mDNS service" OFF)
option(ADD_MQTT "Add MQTT client API" OFF)
#
option(AddMyPlugin "Add my_plugin.c to build" OFF)
if(ADD_WIFI OR ADD_BLUETOOTH)
set(PICO_BOARD pico_w)
endif()
include(pico_sdk_import.cmake)
if(ADD_WIFI OR ADD_ETHERNET)
include(networking/CMakeLists.txt)
include(webui/CMakeLists.txt)
if(ADD_mDNS OR ADD_MQTT)
set(LWIP_DIR ${PICO_SDK_PATH}/lib/lwip)
include(${LWIP_DIR}/src/Filelists.cmake)
endif()
endif()
include(grbl/CMakeLists.txt)
include(fatfs/CMakeLists.txt)
include(motors/CMakeLists.txt)
include(trinamic/CMakeLists.txt)
include(spindle/CMakeLists.txt)
include(sdcard/CMakeLists.txt)
include(keypad/CMakeLists.txt)
include(eeprom/CMakeLists.txt)
include(fans/CMakeLists.txt)
include(bluetooth/CMakeLists.txt)
include(embroidery/CMakeLists.txt)
include(laser/CMakeLists.txt)
include(plugins/CMakeLists.txt)
if(ADD_HPGL)
include(hpgl/CMakeLists.txt)
endif()
project(grblHAL)
pico_sdk_init()
if(AddMyPlugin)
add_executable(grblHAL
main.c
driver.c
serial.c
usb_serial.c
stdio_usb_descriptors.c
flash.c
i2c.c
spi.c
PCA9654E.c
ioports.c
ioports_analog.c
tmc_uart.c
MCP3221.c
my_plugin.c
boards/pico_cnc.c
boards/btt_skr_pico_10.c
littlefs/lfs.c
littlefs/lfs_util.c
littlefs_hal.c
)
else()
add_executable(grblHAL
main.c
driver.c
serial.c
usb_serial.c
stdio_usb_descriptors.c
flash.c
i2c.c
spi.c
PCA9654E.c
ioports.c
ioports_analog.c
tmc_uart.c
MCP3221.c
boards/pico_cnc.c
boards/btt_skr_pico_10.c
littlefs/lfs.c
littlefs/lfs_util.c
littlefs_hal.c
)
endif()
pico_generate_pio_header(grblHAL ${CMAKE_CURRENT_LIST_DIR}/driverPIO.pio)
target_compile_definitions(grblHAL PUBLIC RP2040)
target_compile_definitions(grblHAL PUBLIC NEW_FATFS)
target_compile_definitions(grblHAL PUBLIC LITTLEFS_ENABLE=1)
if(ADD_WIFI)
target_compile_definitions(grblHAL PUBLIC WIFI_ENABLE=1)
target_compile_definitions(grblHAL PUBLIC NDEBUG)
target_sources(grblHAL PRIVATE
wifi.c
dhcpserver.c
)
target_link_libraries(grblHAL PRIVATE
pico_cyw43_arch_lwip_poll
)
endif()
if(ADD_ETHERNET)
target_compile_definitions(grblHAL PUBLIC ETHERNET_ENABLE=1)
target_compile_definitions(grblHAL PUBLIC CYW43_LWIP=0)
target_compile_definitions(grblHAL PUBLIC LWIP_NOASSERT)
include(networking/wiznet/CMakeLists.txt)
target_sources(grblHAL PRIVATE
w5x00_ll_driver.c
)
target_link_libraries(grblHAL PRIVATE
wiznet
pico_lwip
pico_lwip_nosys
)
endif()
if(ADD_WIFI OR ADD_ETHERNET)
target_compile_definitions(grblHAL PUBLIC WEBUI_AUTO_REPORT_INTERVAL=0)
if(ADD_mDNS)
target_compile_definitions(grblHAL PUBLIC LWIP_IGMP=1)
target_compile_definitions(grblHAL PUBLIC LWIP_NUM_NETIF_CLIENT_DATA=1)
target_compile_definitions(grblHAL PUBLIC LWIP_MDNS_RESPONDER=1)
target_compile_definitions(grblHAL PUBLIC MDNS_MAX_SERVICES=8)
target_compile_definitions(grblHAL PUBLIC MDNS_ENABLE=1)
target_sources(grblHAL PRIVATE
${lwipmdns_SRCS}
)
endif()
if(ADD_MQTT)
target_compile_definitions(grblHAL PUBLIC MQTT_ENABLE=1)
target_sources(grblHAL PRIVATE
${lwipmqtt_SRCS}
)
endif()
target_link_libraries(grblHAL PRIVATE
networking
webui
)
endif()
if(ADD_BLUETOOTH)
target_compile_definitions(grblHAL PUBLIC BLUETOOTH_ENABLE=1)
target_compile_definitions(grblHAL PUBLIC NDEBUG)
target_sources(grblHAL PRIVATE
bt_native.c
)
target_include_directories(grblHAL PRIVATE ${PICO_SDK_PATH}/lib/btstack/src)
target_link_libraries(grblHAL PRIVATE
pico_btstack_classic
pico_btstack_ble
pico_btstack_cyw43
)
if(NOT ADD_WIFI)
target_compile_definitions(grblHAL PUBLIC CYW43_LWIP=0)
target_link_libraries(grblHAL PRIVATE
pico_cyw43_arch_poll
)
endif()
endif()
if(AddMyPlugin)
target_sources(grblHAL PRIVATE
my_plugin.c
)
endif()
if(ADD_HPGL)
target_sources(grblHAL PRIVATE
boards/citoh_cx6000.c
)
target_link_libraries(grblHAL PRIVATE
hpgl
)
endif()
target_include_directories(grblHAL PRIVATE ${CMAKE_CURRENT_LIST_DIR})
target_link_libraries(grblHAL PRIVATE
grbl
fatfs
sdcard
motors
trinamic
spindle
keypad
fans
laser
bluetooth
eeprom
misc_plugins
embroidery
tinyusb_device_unmarked
pico_stdlib
pico_unique_id
hardware_dma
hardware_uart
hardware_pio
hardware_i2c
hardware_spi
hardware_gpio
hardware_pwm
hardware_rtc
hardware_clocks
hardware_flash
)
pico_add_extra_outputs(grblHAL)
unset(ADD_WIFI CACHE)
unset(ADD_ETHERNET CACHE)
unset(ADD_BLUETOOTH CACHE)
unset(ADD_HPGL CACHE)
unset(ADD_mDNS CACHE)
unset(AddMyPlugin CACHE)