-
Notifications
You must be signed in to change notification settings - Fork 16
/
CMakeLists.txt
101 lines (80 loc) · 2.65 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
cmake_minimum_required(VERSION 3.13)
option(USB_CONSOLE "build for USB console, otherwise UART" ON)
option(FORCE_TESTS "build release with tests cmd" OFF)
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)
include($ENV{PICO_SDK_PATH}/external/pico_sdk_import.cmake)
if (USB_CONSOLE)
set(PSHELL pshell_usb)
else()
set(PSHELL pshell_uart)
endif()
project(${PSHELL} C CXX ASM)
pico_sdk_init()
if (PICO_SDK_VERSION_STRING VERSION_LESS "1.5.1")
message(FATAL_ERROR "Raspberry Pi Pico SDK version 1.5.1 (or later) required.")
endif()
find_package(Git REQUIRED)
execute_process(
COMMAND git describe
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE PSHELL_GIT_TAG
)
add_subdirectory(littlefs)
add_subdirectory(disassembler)
add_subdirectory(vi)
add_subdirectory(cc)
add_subdirectory(misc)
add_subdirectory(xymodem)
if ("${PICO_BOARD}" STREQUAL "vgaboard")
add_subdirectory(sdio)
else()
add_subdirectory(flashio)
endif()
add_executable(${PSHELL}
main.c
)
target_compile_definitions(${PSHELL} PUBLIC
PICO_MALLOC_PANIC=0
PSHELL_GIT_TAG=\"${PSHELL_GIT_TAG}\"
)
if (FORCE_TESTS)
target_compile_definitions(${PSHELL} PUBLIC PSHELL_TESTS)
endif()
target_include_directories(${PSHELL} PUBLIC ${CMAKE_CURRENT_LIST_DIR}/misc/${FS_DIR})
if ("${PICO_BOARD}" STREQUAL "pico2")
pico_set_linker_script(${PSHELL} ${CMAKE_CURRENT_LIST_DIR}/misc/pshell_2350.ld)
else()
pico_set_linker_script(${PSHELL} ${CMAKE_CURRENT_LIST_DIR}/misc/pshell.ld)
endif()
if (USB_CONSOLE)
pico_enable_stdio_uart(${PSHELL} 0)
pico_enable_stdio_usb(${PSHELL} 1)
else()
pico_enable_stdio_uart(${PSHELL} 1)
pico_enable_stdio_usb(${PSHELL} 0)
endif()
#pico_set_program_name(${PSHELL} "pshell")
#pico_set_program_version(${PSHELL} "${PSHELL_GIT_TAG}")
target_link_libraries(${PSHELL} PUBLIC
littlefs disassembler io vi cc misc xymodem
pico_stdlib pico_rand
hardware_flash hardware_sync hardware_watchdog hardware_timer hardware_gpio
hardware_pwm hardware_adc hardware_clocks hardware_uart hardware_i2c
hardware_spi hardware_irq hardware_dma)
pico_add_extra_outputs(${PSHELL})
message("-----------------------------------------------------")
message("-- CMake ${CMAKE_VERSION}")
message("-- Build ${CMAKE_BUILD_TYPE} / ${CMAKE_SYSTEM_NAME}")
if (USB_CONSOLE)
message("-- USB_CONSOLE ${USB_CONSOLE}, using USB")
else()
message("-- USB_CONSOLE ${USB_CONSOLE}, using UART")
endif()
if ("${PICO_BOARD}" STREQUAL "vgaboard")
message("-- building for ${PICO_BOARD}, using SD card file system")
else()
message("-- building for ${PICO_BOARD}, using flash file system")
endif()
message("-----------------------------------------------------")