-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
147 lines (112 loc) · 3.82 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
cmake_minimum_required(VERSION 3.13)
set(CMAKE_C_STANDARD 11)
# ---------- Version ----------
# set(VERSION_MAJOR 0)
# set(VERSION_MINOR 2)
# set(VERSION_PATCH 0)
# ---------- Pico SDK Project Setup ----------
# Importing the pico-sdk importer
include(external/pico-sdk/pico_sdk_init.cmake)
# setting FreeRTOS path
set(FREERTOS_KERNEL_PATH "${CMAKE_SOURCE_DIR}/external/freertos")
include(${FREERTOS_KERNEL_PATH}/portable/ThirdParty/GCC/RP2040/FreeRTOS_Kernel_import.cmake)
# Project
project(CMS_Avionics_Code)
pico_sdk_init()
set(stdlibs pico_stdlib hardware_gpio hardware_adc hardware_spi hardware_dma hardware_uart pico_bootsel_via_double_reset FreeRTOS-Kernel)
# To make sure build folder doesn't get cluttered
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
add_compile_options(
-Wall # Enable all warnings
-O3 # I am speed
-Werror # Treat warnings as errors
-Wno-unused-variable # annoying, don't keep it tho
-Wno-unused-but-set-variable
-Wno-unused-function # FreeRTOS
-Wno-strict-aliasing # pico-sdk fails this
)
if(PICO_PLATFORM MATCHES "host")
add_compile_options(
-Wno-error # host compilation redefines shit for some reason, and it prevents compilation
)
endif()
# ---------- MPack ----------
set(MPACK_STDIO 0)
set(MPACK_FLOAT 0)
set(MPACK_DOUBLE 0)
file(GLOB_RECURSE mpack_srcs external/mpack/src/mpack/*.c)
file(GLOB_RECURSE mpack_hdrs external/mpack/src/mpack/*.h)
add_library(mpack ${mpack_srcs} ${mpack_hdrs})
target_include_directories(mpack PUBLIC external/mpack/src/mpack)
# --------- Git Describe ---------
execute_process(
COMMAND git describe --tags --dirty
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_DESCRIBE_STRING
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# ---------- Libraries ----------
set(libs
mpack
)
macro(psp_lib loc libname)
file(GLOB_RECURSE srcs ${loc}/${libname}/*.c)
add_library(${libname} INTERFACE)
target_sources(${libname} INTERFACE ${srcs})
target_link_libraries(${libname} INTERFACE ${stdlibs} ${libs})
target_include_directories(${libname} INTERFACE ${loc}/${libname}/include)
list(APPEND libs ${libname})
endmacro()
# this one is special
include_directories(lib/crypto/include)
# list these in topoligical order
psp_lib(lib freertos_config)
psp_lib(lib psp)
psp_lib(device w5500)
psp_lib(device max31856)
psp_lib(device ads13x)
psp_lib(device w25n01)
psp_lib(device mydma)
psp_lib(device myspi)
# psp_lib(device myuart)
psp_lib(lib util)
psp_lib(lib crypto)
psp_lib(lib sensornet)
psp_lib(lib mpack-socket)
# psp_lib(lib commandnet)
psp_lib(lib cmdnet-v2)
psp_lib(lib ntp)
psp_lib(lib state-machine)
# ---------- Boards ----------
set(boards
# emu-rtos
# adc-test
# w5500-test
# ntp-test
# mfc-main
mfc-validation
# emu-validation
)
foreach(board ${boards})
message("Adding board: ${board}")
file(GLOB_RECURSE srcs src/${board}/*.c)
file(GLOB_RECURSE hdrs src/${board}/*.h)
add_executable(${board} ${srcs} ${hdrs})
target_include_directories(${board} PUBLIC src/${board}/)
target_link_directories(${board} PUBLIC src/${board}/)
pico_set_program_name(${board} "${board}")
pico_set_program_version(${board} "${GIT_DESCRIBE_STRING} (build ${CMAKE_BUILD_TYPE})")
set_target_properties(${board}
PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/elf
)
target_link_libraries(${board} ${stdlibs} ${libs} FreeRTOS-Kernel)
pico_enable_stdio_usb(${board} 1)
pico_enable_stdio_uart(${board} 0)
pico_set_binary_type(${board} copy_to_ram) # run full program from ram
# pico_set_float_implementation(${board} none)
pico_add_uf2_output(${board})
endforeach()