/
CMakeLists.txt
101 lines (78 loc) 路 2.73 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
if(TESTS)
cmake_minimum_required(VERSION 2.8)
project(tests)
if(DEBUG)
add_definitions(-DDEBUG)
endif()
if(KIA_SOUL)
add_definitions(-DKIA_SOUL)
endif()
add_subdirectory(brake/tests)
add_subdirectory(can_gateway/tests)
add_subdirectory(steering/tests)
add_subdirectory(throttle/tests)
add_subdirectory(common/libs/pid/tests)
add_custom_target(
run-unit-tests
DEPENDS
run-brake-unit-tests
run-can-gateway-unit-tests
run-steering-unit-tests
run-throttle-unit-tests)
add_custom_target(
run-property-tests
DEPENDS
run-brake-property-tests
run-steering-property-tests
run-throttle-property-tests)
add_custom_target(
run-library-property-tests
DEPENDS
run-pid-library-property-tests)
add_custom_target(
run-all-tests
DEPENDS
run-unit-tests
run-property-tests)
else()
set(CMAKE_TOOLCHAIN_FILE common/toolchain/ArduinoToolchain.cmake)
cmake_minimum_required(VERSION 2.8)
project(firmware)
set(CMAKE_CFLAGS "-std=gnu11 -Os")
set(CMAKE_CXX_FLAGS "-std=gnu++11 -Os")
option(DEBUG "Enable debug mode" OFF)
option(KIA_SOUL "Build firmware for Kia Soul" OFF)
option(BRAKE_STARTUP_TEST "Enable brake startup sensor tests" ON)
set(SERIAL_PORT_BRAKE "/dev/ttyACM0" CACHE STRING "Serial port of the brake module")
set(SERIAL_BAUD_BRAKE "115200" CACHE STRING "Serial baud rate of the brake module")
set(SERIAL_PORT_CAN_GATEWAY "/dev/ttyACM0" CACHE STRING "Serial port of the CAN gateway module")
set(SERIAL_BAUD_CAN_GATEWAY "115200" CACHE STRING "Serial baud rate of the CAN gateway module")
set(SERIAL_PORT_STEERING "/dev/ttyACM0" CACHE STRING "Serial port of the steering module")
set(SERIAL_BAUD_STEERING "115200" CACHE STRING "Serial baud rate of the steering module")
set(SERIAL_PORT_THROTTLE "/dev/ttyACM0" CACHE STRING "Serial port of the throttle module")
set(SERIAL_BAUD_THROTTLE "115200" CACHE STRING "Serial baud rate of the throttle module")
if(DEBUG)
add_definitions(-DDEBUG)
endif()
if(KIA_SOUL)
add_definitions(-DKIA_SOUL)
else()
message(WARNING "No platform selected - no firmware will be built")
endif()
if(BRAKE_STARTUP_TEST)
add_definitions(-DBRAKE_STARTUP_TEST)
else()
message(WARNING "Brake sensor startup tests disabled")
endif()
add_subdirectory(brake)
add_subdirectory(can_gateway)
add_subdirectory(steering)
add_subdirectory(throttle)
add_custom_target(
all-upload
DEPENDS
brake-upload
can-gateway-upload
steering-upload
throttle-upload)
endif()